Hi Berra, There are numerous ways to estimate power spectral density - and I recommend you look into which suits your needs best. But for now to answer your question. There are a couple of errors in your code. Most importantly, your sampling frequency is a little too small. As a rule of thumb allow a bit more than the Nyquist rate (2.5 times the maximum frequency should be enough). The PSD is a measurement at various frequencies, so: Pyy = Y.*conj(Y)/8192; % estimated over the FFT size Now to graph, you only need to plot the first 4096 points, as the other 4096 points are symmetric. Use: f=Fs*(0:4095)/8192; plot(f,Pyy(1:4096)) Put this all together gives: Fs'00; t = [0:1/Fs:1]; x=sin(2*pi*300*t)+sin(2*pi*330*t); y=sin(2*pi*700*t)+sin(2*pi*900*t); X = fft(x,8192); Y = fft(y,8192); f=Fs*(0:4095)/8192; Pyy=Y.*conj(Y)/8192; Pxx=X.*conj(X)/8192; plot(f,Pyy(1:4096)) hold plot(f,Pxx(1:4096),'g') You should see your spectral peaks at 300Hz, 330Hz (in green) and 700Hz, 900Hz in blue. I would also suggest you use a window to reduce spectral leakage, something like: W=blakman(length(y)); Yt((y.*W'),8192); You can then compare the windowed and non-windowed responses. Matlab has several PSD estimation algorithms, type > help psd at the matlab prompt for details. Hope this helps, Jeff -----Original Message----- From: berra tosun [mailto:] Sent: Wednesday, October 16, 2002 7:33 PM To: Subject: [matlab] Power Spectral Density Hi there, I need to find the power spectral densities of the following signals: t = [0:1/1800:1]; x=sin(2*pi*300*t)+sin(2*pi*330*t); y=sin(2*pi*700*t)+sin(2*pi*900*t); X = fft(x,8192); Y = fft(y,8192); f=[0:8191]/8192; Pyy=Y.*conj(Y)/abs(Y); Pxx=X.*conj(X)/abs(X); when i plot (f,Pyy ) , the resulting graphich seems to be wrong.. Could you please tell me what am i doing wrong?.. Thank you very much Berra _____________________________________ Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group. _____________________________________ About this discussion group: To Join: To Post: To Leave: Archives: http://www.yahoogroups.com/group/matlab More DSP-Related Groups: http://www.dsprelated.com/groups.php3 ">http://docs.yahoo.com/info/terms/ |