Find Fourier transform of signal and amplitude and phase spectra of it using matlab

 To Find Fourier transform of signal and amplitude and phase spectra of it using Matlab Follow simple step :

[1] Open a MATLAB and goto file -> New -> M-file

[2] write this code in your M-file :

Ts=1/64;
T0=4;
N0=T0/Ts;
t=0:Ts:Ts*(N0-1) ;                                                
t=t';
g=Ts*exp(-2 *t);
g(1)=Ts*0.5;
G=fft(g);

[ Gp,Gm]=cart2pol(real(G), imag(G));
k=0:N0-1 ;
k=k';
w=2*pi*k/T0;
subplot(211);
stem(w(1:32), Gm(1:32));
title('magnitude spectra') ; subplot(212);
stem(w(1:32), Gp(1:32));
title('phase spectral') ;

[3]   After writing this code save your M-file and run it after running your program you will get output as                 shown below.which is nothing but our amplitude and phase spectra of our signal.



Comments

Popular posts from this blog

MATLAB program to find Frequency Modulation