Is there an error in the documentation of PMTM function in Signal Processing Toolbox 6.2 (R14)?

Illustration
Charlottemia - 2021-03-15T09:49:27+00:00
Question: Is there an error in the documentation of PMTM function in Signal Processing Toolbox 6.2 (R14)?

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.  

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
 
We have verified that the example in the PMTM function  documentation is incorrect in Signal Processing  Toolbox 6.2 (R14).
 
To work around this issue, please use the following code instead:
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)


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!