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

Introduction to this Blog

In this blog we are willing to accumulate useful information related to the hot topic in market : Digital Signal Processing !! | Starting with very basics this blog would lead to you some interesting topics in DSP which will help you a lot !

Circular Convolution of the two Sequences

The program code is : clc clear all close all X1=input('ENTER THE SEQUENCE 1 >'); i1=input('ENTER THE STARTING INDEX OF THE SEQUENCE 1 >'); X2=input('ENTER THE SEQUENCE 2 >'); i2=input('ENTER THE STARTING INDEX OF THE SEQUENCE 2 >'); m1=length(X1); m2=length(X2); if(m1>m2)     Y=cconv(X1,X2,m1)     n3=(i1+i2):(i1+i2+m1-1); else     Y=cconv(X1,X2,m2)     n3=(i1+i2):(i1+i2+m2-1); end Yref=conv(X1,X2) n1=i1:i1+m1-1; n2=i2:i2+m2-1; n4=(i1+i2):(length(Yref)-1+i1+i2); subplot(4,1,1) stem(n1,X1,'r') xlabel('n'); ylabel('Amplitude'); title('Sequence 1'); subplot(4,1,2) stem(n2,X2,'g') xlabel('n'); ylabel('Amplitude'); title('Sequence 2'); subplot(4,1,3) stem(n3,Y,'c') xlabel('n'); ylabel('Amplitude'); title('Circular Convolution of the Above two sequences'); subplo...

DFT and IDFT using Mathematical Formula

dftidft2 clc clear all close all X=input( 'Enter the Input Sequence' ); N=input( 'Enter the N value such that N-point DFT is calculated' ); %Inputs are given% L=length(X); if N>L X=[X zeros(1,N-L)]; else X=X(1:N); end %Adjusting the Length of the input Sequence by appending Zeros or truncating the sequence% for k=1:N key=0; for n=1:N key=key+X(n)*exp(-(j*2*pi*(k-1)*(n-1))/N); end Y(k)=key; end %DFT is calculated% Y %DFT is printed% 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% for k=1:N key=0; for n=1:N key=key+Y(n)*exp((j*2*pi*(k-1)*(n-1))/N); end Yinv(k)=key/N; end %IDFT is calculated% Yinv L=length(Y); n=0:1:L-1; figure,plot(n,abs(Yinv)),title( 'Magnitude Response of IDFT' ) figure, plot(n, ang...