Skip to main content

Verification of Fourier Transform

What is Fourier Transform :

Fourier Transform is a incredible method of finding the frequencies present in a signal. When we apply fourier transform we get a impulse at that particular sinusoidal frequency present in the incoming signal.
Suppose that the signal is generated using three frequencies fm1 , fm2 and fm3. Now when we observe the fourier transform of this signal we can see three impulses at fm1 , fm2 and fm3.

So in this program we are going to generate a random signal and note down the frequencies present in that signal. The after applying fourier transform we can check whether we have impulses at that frequencies or not.

Algorithm :

Step 1 : We are going to generate a random signal.

Step 2 : Apply fourier transform to that signal.
Step 3 : Verify.

Program Code :
 clc
clear all
close all
fs=input('Enter the sampling frequency');
t=0:1/fs:1;
X=sin(2*pi*0*t);
n=input('Enter the number of frequencies');
frequencies=[];
for i=1:n
    fm=randi(fs/2);
    X=X+sin(2*fm*t*pi);
    frequencies =[frequencies fm];
end
y=fft(X);
keyttu=fftshift(y);
N=-fs/2:1:fs/2;
plot(N,abs(keyttu));

frequencies=sort(frequencies)


Inputs Given :


Output :

Comments

Popular posts from this blog

DFT and IDFT using Matrix Multiplication Method in Matlab

dftidft3 clc clear all close all X=input( 'Enter the Input Sequence' ); N=input( 'Enter the value of N such taht N-point DFT is to be calculated' ); %Inputs are taken% n=0:1:N-1; k=0:1:N-1; nk=n'*k; %n transpose * k gives us a N*N matrix% W=exp(-(j*2*pi)/N); % Twiddle Factor % Wnk=W.^nk; % Twiddle Factor matrix is generated % Y= Wnk*X' ; % Twiddle factor matrix multiplied by X transpose% %Reason behing going to Transopose of the input matrix is : when we enter a matrix sequence we usually use ROW Matrix, in order to convert ROW to COLUMN we are using Transpose% L=length(Y); n=0:1:L-1; figure,plot(n,abs(Y)),title( 'Magnitude Response of DFT' ) figure, plot(n, angle(Y)), title( 'Phase Response of DFT' ) %MAGNITUDE and PHASERESPONSE OF DFT SIGNAL IS PLOTTED% W=exp((j*2*pi)/N); % Twiddle Factor % Wnk=(W.^nk)/N; % Twiddle Factor matrix is generated % Yinv= Wnk*Y ; % Twiddle factor matrix multiplied by Y% L=length...

DFT and IDFT using FFT command in Matlab

dftidft1 clc clear all close all X=input( 'Enter the Input Sequence' ); N=input( 'Enter the Value of N such that N-point DFT is to be Calculated' ); % INPUTS ARE GIVEN % Y= fft(X,N) %DFT IS CALCULATED% L=length(Y); n=0:1:L-1; figure,plot(n,abs(Y)),title( 'Magnitude Response of DFT' ) figure, plot(n, angle(Y)), title( 'Phase Response of DFT' ) %MAGNITUDE and PHASERESPONSE OF DFT SIGNAL IS PLOTTED% Yinv=ifft(Y,N) %IDFT IS CALCULATED% figure,plot(n,abs(Yinv)),title( 'Magnitude Response of IDFT' ) figure, plot(n, angle(Yinv)), title( 'Phase Response of IDFT' ) %MAGNITUDE and PHASERESPONSE OF ORIGINAL SIGNAL IS PLOTTED% Error using input Cannot call INPUT from EVALC. Error in dftidft1 (line 5) X=input('Enter the Input Sequence'); Published with MATLAB® R2013b