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

C
Charlottemia · Mar 15, 2021 · 2.1K views
Question
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 PhD Expert
Answered Aug 25, 2026
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)
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!