How to have a surf plot displayed in a GUI (not as an external figure).

28 Ansichten (letzte 30 Tage)
I'm needing to have a surf plot displayed in the GUI I'm working on, not as an external figure. This is to display the various frequencies across time. This is the code I have at the moment.
[sabz,cFreq,timeInst] = spectrogramAnal(app.trace,app.Fs,app.baseline(1),app.baseline(2));
surf(app.UIAxes,timeInst, cFreq, sabz, 'EdgeColor', 'none');
axis xy;
axis tight;
colormap(jet); view(0,90);
caxis([0, 10]);
xlabel('Time (s)');
colorbar;
ylabel('Frequency (Hz)');
The spectrogramAnal function just sets up the data for the surf plot. My masters supervisor wrote the script for a surf plot to be done as an external figure but wants me to make it so that it will display the plot in the app itself. However, I can't seem to get it to work. Any ideas?
  8 Kommentare
Mark Gauthier-Braham
Mark Gauthier-Braham am 29 Mai 2020
Bearbeitet: Cris LaPierre am 29 Mai 2020
It starts making the external figure right after it steps past the surf code.
No changes have been made to spectrogramAnal. The origional code was just:
[sabz,cFreq,timeInst] = spectrogramAnal(app.trace,app.Fs,app.baseline(1),app.baseline(2));
surf(timeInst, cFreq, sabz, 'EdgeColor', 'none');
axis xy;
axis tight;
colormap(jet); view(0,90);
caxis([0, 10]);
xlabel('Time (s)');
colorbar;
ylabel('Frequency (Hz)');
So, the only change I made was adding in the app.UIAxes part.
Cris LaPierre
Cris LaPierre am 29 Mai 2020
And if you remove the app.UIAxes from you updated code, does the surf plot appear still correctly in an external figure window?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ameer Hamza
Ameer Hamza am 30 Mai 2020
You need to pass app.UIAxes to all the other functions too. Otherwise, they will also create a new figure window.
surf(app.UIAxes, timeInst, cFreq, sabz, 'EdgeColor', 'none');
axis(app.UIAxes, 'xy');
axis(app.UIAxes, 'tight');
colormap(app.UIAxes, jet);
view(app.UIAxes, [0,90]);
caxis(app.UIAxes, [0, 10]);
xlabel(app.UIAxes, 'Time (s)');
ylabel(app.UIAxes, 'Frequency (Hz)');
colorbar(app.UIAxes);

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by