Finding the Fourier transform of a given signal and plotting its magnitude and phase spectrum 

Aim: To find the Fourier transform of a given signal and plotting its magnitude and phase spectrum

EQUIPMENT:

PC with windows (95/98/XP/NT/2000).

MATLAB Software

Theory:

Program : To compute n-point FFT

Program:

clc;
close all;
clear all;
x=input('enter the sequence');
N=length(x);
n=0:1:N-1;
y=fft(x,N)
subplot(2,1,1);
stem(n,x);
title('input sequence');
xlabel('time index n----->');
ylabel('amplitude x[n]----> ');
subplot(2,1,2);
stem(n,y);
title('output sequence');
xlabel(' Frequency index K---->');
ylabel('amplitude X[k]------>');

Output:

n-point FFt

Program: FFT magnitude and Phase plot:

clc
close all
x=[1,1,1,1,zeros(1,4)];
N=8;
X=fft(x,N);
magX=abs(X),phase=angle(X)*180/pi;
subplot(2,1,1)
plot(magX);
grid
xlabel('k')
ylabel('X(K)')
subplot(2,1,2)
plot(phase);
grid
xlabel('k')
ylabel('degrees')

Output:

Program: This program finds the Fourier Transform of exp(-At)

Defining the Time domain signal x(t)=exp(-At)

A=input('enter the constant of decay')
T=input('énter the increment for time axis')
T1=input('enter the upper bound for time axis')
t=0:T:T1;
x=exp(-A*t);
w=t
w1=-fliplr(w)
w2=[w1 w]
%Defining Fourier Transform
ft=x*exp(-i*t'*w)*T;
%Magnitude of Fourier Transform
a=abs(ft);
a1=fliplr(a)
a2=[a1 a]
%computing phase spectrum
p=angle(ft);
p1=-fliplr(p)
p2=[p1 p]
subplot(3,1,1)
plot(t,x)
xlabel('time')
ylabel('amplitude')
grid
title('The given exponential signal')
subplot(3,1,2)
plot(w2,a2)
xlabel('frequency')
ylabel('amplitude')
grid
title('Magnitude Spectrum')
subplot(3,1,3)
plot(w2,p2)
xlabel('frequency')
ylabel('phase angle')
grid
title('Phase Spectrum ')

 RESULT

enter the constant of decay 1

A = 1

énter the increment for time axis 0.01  

T = 0.0100

enter the upper bound for time axis 10

T1 =10

Output:

Result: In this experiment the Fourier transform of a given signal and plotting its magnitude and phase spectrum have been demonstrated using matlab.