Spectrogram error: psdoptions and nfft

조회 수: 6 (최근 30일)
Michael
Michael 2023년 7월 28일
답변: Michael 2023년 7월 28일
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