Spectrogram error: psdoptions and nfft

7 次查看(过去 30 天)
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?

采纳的回答

Michael
Michael 2023-7-28
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Time-Frequency Analysis 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by