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.
[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?