Spectrogram error: psdoptions and nfft

3 Ansichten (letzte 30 Tage)
Michael
Michael am 28 Jul. 2023
Beantwortet: Michael am 28 Jul. 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?

Akzeptierte Antwort

Michael
Michael am 28 Jul. 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!

Weitere Antworten (0)

Kategorien

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

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by