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

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일
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일
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