MATLAB Answers

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

7 views (last 30 days)
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
Error using
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)
Error in pspectrum>computeSpectrogram (line 451)
Error in pspectrum (line 251)
[P,F,TORPWR] = computeSpectrogram(opts, nargout==0);
Error in test_27apr (line 17)


Sign in to comment.

Accepted Answer

Deepak Gupta
Deepak Gupta on 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));
Hope this helps.

  1 Comment

Ana Caramete
Ana Caramete on 28 Apr 2020
Thank you very much! Normalising solved the problem indeed.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!