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

densitiesdensitymultitaperpmtmpowerpsdSignal Processing Toolboxspectralspectrum

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.

Best Answer

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)