MATLAB r2010a, i got error for help example !!!!WHY and HOW ??

Hi , when i the used pmtm function for spectrum estimation i got an error here the code which is exactly the help example
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);
plot(hpsd)
I got this error
Error in ==> computepsd at 28
if nargin < 7
??? Output argument "varargout{4}" (and maybe others) not assigned during call to
"C:\Program Files\MATLAB\R2010a\toolbox\signal\signal\computepsd.m>computepsd".
Error in ==> pmtm at 118
[Pxx,Sxx,f,units] = computepsd(S,w,params.range,params.nfft,params.Fs);
Can you help me to solve the problem.Thanks

1 件のコメント

Tobias
Tobias 2013 年 4 月 8 日
You should really make use of the code syntax provided by the forum. Make use of the preview of your message, if you are insecure whether it worked or not.
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);
plot(hpsd)
In the end, it makes it much easier on people's eyes when trying to figure out what went wrong

サインインしてコメントする。

回答 (3 件)

Andreas Goser
Andreas Goser 2013 年 4 月 8 日

0 投票

Your code works on my installation (Relase 2012b, Win7). Just in case you have the product installed, but something goes wrong with the license, can you run the command
license('test', 'signal_toolbox')
It should return "1".
In case this doesn't help, put your code into a script and then step through the code in the editor (debugging) and see what exactly happens in line 118 of pmtm.m.
Image Analyst
Image Analyst 2013 年 4 月 8 日
編集済み: Image Analyst 2013 年 4 月 8 日

0 投票

Worked fine for me. What does this say:
>> which -all pmtm
It should say:
C:\Program Files\MATLAB\R2013a\toolbox\signal\signal\pmtm.m
Try this code:
hasSPT = license('test', 'signal_toolbox')
if ~hasSPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Signal Processing Toolbox licensed or installed properly.');
uiwait(warndlg(message));
end
Usama H
Usama H 2013 年 4 月 8 日
編集済み: Usama H 2013 年 4 月 8 日

0 投票

Ok, thanks for fast answers i found the problem >> i have another function in my current directory has the same name pmtm thank you guys ^_6

1 件のコメント

Image Analyst
Image Analyst 2013 年 4 月 8 日
編集済み: Image Analyst 2013 年 4 月 8 日
This should have been a comment, not an answer. Glad that my suggestion to use "which" solved it for you. Go ahead and mark my answer above as Accepted.

サインインしてコメントする。

カテゴリ

質問済み:

2013 年 4 月 8 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by