MATLAB: How to display spectrogram of a audio in App Designer

app designerMATLABspectrogram

I want show the figure in the app designer interface.But did not success.I only can plot it outside of app designer.I am using Matlab 2018b.
spectrogram(audio,window,noverlap,nfft,fs,'yaxis');
Anyone know how to do it. Thanks.

Best Answer

Dear Austin,
You need to specify which axes will be used for plotting, inside a callback for plotting such spectrogram, you may use the following example code:
t = 0:0.001:2;
x = chirp(t,100,1,200,'quadratic');
myAxe = app.UIAxes;
[S,F,T] = spectrogram(x,128,120,128,1e3);
imagesc(myAxe, T, F, log(1+abs(S)) ); %plot the log spectrum
set(myAxe,'YDir', 'normal'); % flip the Y Axis so lower frequencies are at the bottom
Let me know if that solves your problem.