Matlab code for the power spectral density of different line codes using MATLAB.

Code:


clc
clear all;
f=input('enter the freq of signal:');
fs=input('enter the sampling freq of signal:');
N=input('enter the value of N:');

t=0:1/fs:1;
x=square(2*pi*f*t);


y=fft(x,N);
ypower=1/N*(y.*(conj(y)));

ypower=ypower(1,1:(N/2));
xax =0:fs/N:(fs/2)-(fs/N);

subplot 211,plot(x); title('signal');
subplot 212, plot(xax,ypower); title('power spectral density');

Output:


0 comments:

Post a Comment