I tried to run the following commands in the example of the PMTM documentation: randn('state',0); fs = 1000; t = 0:1/fs:0.3; x = cos(2*pi*t*200) + 0.1*randn(size(t)); [Pxx,Pxxc,f] = pmtm(x,3.5,512,fs,0.99); hpsd = dspdata.psd([Pxx Pxxc],{f,fs}) plot(hpsd) I received the following errors: ??? Error using ==> dspdata.abstractfreqresp.initialize The number of frequency points must equal the length of the data.
Prashant Kumar answered .
2025-11-20
randn('state',0);
fs = 1000;
t = 0:1/fs:0.3;
x = cos(2*pi*t*200) + 0.1*randn(size(t));
[Pxx,Pxxc,f] = pmtm(x,3.5,512,fs,0.99);
hpsd = dspdata.psd([Pxx Pxxc],'Fs',fs); % <----- the corrected line
plot(hpsd)