how to display spectrogram of a audio in App Designer

30 Ansichten (letzte 30 Tage)
austin austin
austin austin am 3 Okt. 2018
Kommentiert: Edgar Guevara am 4 Okt. 2018
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.

Akzeptierte Antwort

Edgar Guevara
Edgar Guevara am 3 Okt. 2018
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.
  3 Kommentare
austin austin
austin austin am 3 Okt. 2018
By the way, the way you did, it is work good. But the spectrogram color is a little darker. Is there any way can make it brighter? Thank you.
Edgar Guevara
Edgar Guevara am 4 Okt. 2018
I think your spectrogram is not displayed on log scale, try the following code, which reproduces the output from the built-in function:
methods (Access = private)
% Button pushed function: Button
function plotSpec(app, event)
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, F, T, log(abs(S'))); %plot the log spectrum
set(myAxe,'YDir', 'normal'); % flip the Y Axis so lower frequencies are at the bottom
axis square
axis tight
colorbar
end
end
As you can see:

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Time-Frequency Analysis finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by