MATLAB: Power spectral density PSD

power spectral density

If I am have signal with length(33),or 13 signals each with length(33), How finding PSD to each signal individually?and plot its individually?

Best Answer

You can try this way :
t=linspace(0,1,33);% 1 seconde
Fs=inv(t(3)-t(2));
f=Fs/10;
P=13; % number of signals
X=zeros(33,P);
for n=1:P
X(:,n)=sin(2*pi*t*(f+n));
end
N=512; % number of points for computing DFT
frequency=(0:N-1)*Fs/N; % frequency axis
frequency=frequency(1:floor(end/2)); % One sided spectrum
PSD=zeros(N,P);
for n=1:P
PSD(:,n)=fft(X(:,n),N);
PSD(:,n)=PSD(:,n).*conj(PSD(:,n));
end
PSD(floor(end/2)+1:N,:)=[]; % one sided spectrum
% Plotting them all in one figure
figure,plot(frequency,PSD)