Spectrogram error: psdoptions and nfft

6 vues (au cours des 30 derniers jours)
Michael
Michael le 28 Juil 2023
Réponse apportée : Michael le 28 Juil 2023
I'm getting some error messages trying to use the spectrogram function in Matlab 2022b.
My signal x_re is sized 600000 x 1, with a sampling frequency fs_re of 20000. I'm using a block length Nfft of 5000, and an overlap proportion of 0.5*Nfft, with a Hann window. I'd like to output the power spectrum and the frequency vector.
Nfft = 5000;
overlap = 0.5;
noverlap = overlap*Nfft;
[s, f, t, ps] = spectrogram(x_re, hann(Nfft, 'periodic'), noverlap, nfft=Nfft, fs=fs_re, spectrumtype='power', freqrange='onesided')
The error message I'm getting is as follows:
Error using psdoptions
Expected input to match one of these values:
'half', 'onesided', 'whole', 'twosided', 'adapt', 'unity', 'eigen', 'corr', 'ev', 'centered', 'power', 'psd', 'ms', 'reassigned', 'confidencelevel', 'mean', 'maxhold', 'minhold', 'mimo'
The input, 'nfft', did not match any of the valid values.
Error in signal.internal.spectral.welchparse>welch_options (line 380)
[options1,msg,msgobj] = psdoptions(isreal_x,options,varargin{:});
Error in signal.internal.spectral.welchparse (line 37)
options = welch_options(isreal_x,L,isMimo,esttype,opts{:});
Error in pspectrogram (line 30)
[xw,nx,~,yw,ny,win,~,~,noverlap,~,~,options] = signal.internal.spectral.welchparse(x,esttype,inpArgs{:});
Error in spectrogram (line 191)
[varargout{1:nargout}] = pspectrogram({x},'spect',inpArgs{:});
Can anyone decipher the problem?

Réponse acceptée

Michael
Michael le 28 Juil 2023
It seems the problem is in the argument syntax usage - the function wouldn't accept either Name=Value, or 'Name', 'Value' paired syntax, and checking the built-in help file for 2022b indicates that only MinThreshold and OutputTimeDimension are accepted arguments that use this syntax.
Unsure why Mathworks doesn't make all the arguments syntax consistent; Name=Value seems the most straightforward argument syntax to use!

Plus de réponses (0)

Catégories

En savoir plus sur Time-Frequency Analysis dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by