Filter löschen
Filter löschen

Error when using "pspectrum" with "spectrogram" option.

9 Ansichten (letzte 30 Tage)
Ana Caramete
Ana Caramete am 28 Apr. 2020
Kommentiert: Ana Caramete am 28 Apr. 2020
Hello,
I am trying to plot the pspectrum of a signal, using the following command: pspectrum(SmallY,fs,'spectrogram') and I get the error listed below. SmallY is a 1x100,000 double array (here attached). What puzzles me most is that the same command works for another array, which is a 1x 9000 double (attached here as normal.mat).
Could someone please help with this? I don't see what is the difference between the two arrays, why is one working and the other not. Below, I am also listing the "code", although it's not much. Of course, the same code goes for 'normal' array.
load SmallY
fs=100000;
pspectrum(SmallY,fs,'spectrogram')
-----------------------------------------------------------------------------------------
Error using matlab.graphics.axis.Axes/set
Error setting property 'CLim' of class 'Axes':
Value must be a 1x2 vector of numeric type in which the second element is larger than the
first and may be Inf
Error in signalwavelet.internal.convenienceplot.plotTFR (line 178)
set(ancestor(hndl,'axes'),'CLim',[Pmax plotOpts.threshold]);
Error in pspectrum>displaySpectrogram (line 1078)
signalwavelet.internal.convenienceplot.plotTFR(t,f,10*log10(abs(P)+eps),plotOpts);
Error in pspectrum>computeSpectrogram (line 451)
displaySpectrogram(T,F,P,opts.IsNormalizedFreq,opts.MinThreshold,FRES,TRES);
Error in pspectrum (line 251)
[P,F,TORPWR] = computeSpectrogram(opts, nargout==0);
Error in test_27apr (line 17)
pspectrum(SmallY,fs,'spectrogram')
---------------------------------------------------------------------------------------------------------------

Akzeptierte Antwort

Deepak Gupta
Deepak Gupta am 28 Apr. 2020
Hello Ana,
There is a different between data sets normal and SmallY.
In dataset SmallY, values are extremly small. i.e. max value = 3.0620e-16 and min value = -3.0620e-16. This is what causing the error and pspectrum is unable to support such small numbers.
You can normalise your data before pspectrum to avoid this error.
SmallY = SmallY/max(abs(SmallY));
fs=100000;
pspectrum(SmallY,fs,'spectrogram')
Hope this helps.
cheers.
  1 Kommentar
Ana Caramete
Ana Caramete am 28 Apr. 2020
Hello,
Thank you very much! Normalising solved the problem indeed.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Time-Frequency Analysis 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