Generated script from Signal Analyser app - How to plot spectrogram?

Hi!
I managed to import signal and set settings in Signal Analyser app. I generated script and want to add it to the rest of the code.
Below is the generated script:
% Compute spectrogram
% Generated by MATLAB(R) 9.8 and Signal Processing Toolbox 8.4.
% Generated on: 21-Jan-2021 22:40:31
% Parameters
timeLimits = [0 1.470999]; % seconds
frequencyLimits = [0 120000]; % Hz
timeResolution = 1; % seconds
overlapPercent = 50;
%%
% Index into signal time region of interest
konst_svetlobni_tok_ROI = konst_svetlobni_tok(:);
sampleRate = 1000000; % Hz
startTime = 0; % seconds
timeValues = startTime + (0:length(konst_svetlobni_tok_ROI)-1).'/sampleRate;
minIdx = timeValues >= timeLimits(1);
maxIdx = timeValues <= timeLimits(2);
konst_svetlobni_tok_ROI = konst_svetlobni_tok_ROI(minIdx&maxIdx);
timeValues = timeValues(minIdx&maxIdx);
% Compute spectral estimate
% Run the function call below without output arguments to plot the results
[P,F,T] = pspectrum(konst_svetlobni_tok_ROI,timeValues, ...
'spectrogram', ...
'FrequencyLimits',frequencyLimits, ...
'TimeResolution',timeResolution, ...
'OverlapPercent',overlapPercent);
If I am right, this script does not include command to plot spectrogram.
How can I plot it? What do I have to add to script?
Best regards!

 採用された回答

Cris LaPierre
Cris LaPierre 2021 年 1 月 21 日

0 投票

Look at the comment just above the call to pspectrum. With output arguments assigned, it does not create a spectrogram. However, if you remove the output arguments, it will create the indicated plot (spectrogram here).
pspectrum(konst_svetlobni_tok_ROI,timeValues, ...
'spectrogram', ...
'FrequencyLimits',frequencyLimits, ...
'TimeResolution',timeResolution, ...
'OverlapPercent',overlapPercent);

3 件のコメント

Matic Markovic
Matic Markovic 2021 年 1 月 21 日
Thank you!
I did not know what exactly was meant with "output arguments".
Is it possible to swap x-axis and y-axis?
Cris LaPierre
Cris LaPierre 2021 年 1 月 21 日
It is possible with the spectrogram function (specify 'yaxis' as the freqloc). I don't see a similar setting for pspectrum.
Matic Markovic
Matic Markovic 2021 年 1 月 22 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTime-Frequency Analysis についてさらに検索

製品

リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by