how to computer the certain signal's PSD?

1 view (last 30 days)
qian xuewu
qian xuewu on 23 Jul 2015
Edited: qian xuewu on 23 Jul 2015
if true%%
if i want to computer the psd of the simulation signal by matlab,how to do,the program as follows,please tell me where wrong is
%%%%
clear all;
close all
fs=200;%sample frequency
N=2^10;%sample number
t=[0:N-1]*1/fs;%time
%DC+frequency signal+noise
xn=1+5*sin(2*pi*10*t)+3*sin(2*pi*15*t)+3*sin(2*pi*20*t)+3*sin(2*pi*25*t)+3*sin(2*pi*30*t)+1.0*randn(1,N);
N2=floor(N/2);
%computer PSD
Xk=fft(xn,N);
S1=abs(Xk).^2/N/fs;S1(2:end)=S1(2:end)*2;
semilogy([0:N2-1]*fs/N,sqrt(S1(1:N2)),'b');
grid on,xlabel('frequency/Hz');ylabel({'$${Amp/}\sqrt{Hz}$$'},'interpreter','latex');
title('PSD by FFT')
problem is:
1.if i want to get the unit is Amp/sqrt(Hz),sqrt(Amp^2/Hz)is right?
2.the input signal's harmonic 15Hz,20Hz,25Hz,30Hz Amp is all equal to 3,however,the PSD's output'Amp of signal's corresponding frequency is not equal,why?
3. if my methord is not right,how to do? thank you!

Answers (0)

Community Treasure Hunt

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

Start Hunting!