Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Matlab demo running error, help debug please

Status
Not open for further replies.

neoflash

Advanced Member level 1
Advanced Member level 1
Joined
Jul 2, 2005
Messages
492
Helped
10
Reputation
20
Reaction score
2
Trophy points
1,298
Activity points
4,759
errors in matlab demos

There is a Matlab demo in help file on PSD.

fs = 1000; % Sampling frequency
t = (0:fs)/fs; % One second worth of samples
xn = sin(2*pi*50*t);
Hs = spectrum.periodogram('Hamming');
psd(Hs,xn,'Fs',fs,'NFFT',1024,'SpectrumType','twoside')

[Pxxo,F] = psd(Hs,xn,'Fs',fs,'SpectrumType','onesided');
Pow = (fs/(2*length(Pxxo))) * sum(Pxxo)


However, during running, it reported error as:

??? Error using ==> psd
Too many output arguments.

Error in ==> psd_test2 at 7
[Pxxo,F] = psd(Hs,xn,'Fs',fs,'SpectrumType','onesided');


what is wrong with this demo?

thanks.
 

Hi
I tested the codes in MATLAB 7 and it worked well.
here is the graph.
cheers
 

what is the value you get for POW?
 

Hi
ecuse me if the file wasn't uploaded my system cannot properly upload the file.
as i read matlab help, psd cannot output frequency as it's written and it creates an object data .
try command :'pwelch' instead.
 

    neoflash

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top