Showing posts with label idft. Show all posts
Showing posts with label idft. Show all posts

Thursday, September 15, 2011

Discrete Fourier Transform & Inverse Discrete Transform (DFT AND IDFT)


3. Discrete Fourier Transform & Inverse Discrete Transform (DFT AND IDFT)



AIM: To develop a program for Computing DFT and IDFT in MATLAB

REQUIREMENTS: MATLAB 7.5

Learning Objectives: To make the students familiar with concept of DFT and IDFT with
the use of MATLAB.

THEORY: The discrete Fourier transform (DFT) X[k] of a finite-length sequence x[n] can be
easily computed in MATLAB using the function fft. There are two versions of this function.
fft(x) computes the DFT X[k] of the sequence x[n] where the length of X[k] is the same as that of
x[n]. fft(x,L) computes the L-point DFT of a sequence x[n] of length N where L = N. If L > N,
x[n] is zero-padded with L-N trailing zero-valued samples before the DFT is computed. The
inverse discrete Fourier transform (IDFT) x[n] of a DFT sequence X[k] can likewise be computed
using the function ifft, which also has two versions.

ALGORITHM (For DFT):
1 Enter the input Sequence ,x having length=4
2 Set the range of k according to the length of x.
3 Computing DFT, store the value in X(k).
4 Plotting the DFT of given Sequence,store in X(k).

PROGRAM CODE:
% Program to perform Discrete Fourier Transform:
clc;
clear all;
close all hidden;
x=input('The given i/p sequence is x(n): ');
subplot(2,2,[1,2]), stem(x);
title('i/p sequencce x(n)is:');
xlabel('---->n');
ylabel('---->x(n)');grid;
N=length(x);
for k=1:N
X(k)=0;
for n=1:N
X(k)=X(k)+x(n).*exp(-j.*2.*pi.*(n-1).*(k-1)./N);
end
end
disp('The DFT of the i/p sequence x(n) is X(n):')
p=0:(N-1);
subplot(2,2,[3,4]), stem(p,abs(X));
title('The DFT of the i/p sequence x(n) is X(n):');
xlabel('---->n');
 ylabel('---->X(n)');grid;
disp(X);

ALGORITHM (For IDFT):

1 Enter the input Sequence, x having length=4
2 Set the range of k according to the length of x.
3 Computing IDFT, store the value in X(k).
4 Plotting the IDFT of given Sequence, store in X(k).

% Program to perform Inverse Discrete Fourier Transform:
clc;
clear all;
close all hidden;
X=input('The given i/p sequence is X(n): ');
subplot(2,2,[1,2]), stem(X);
title('i/p sequencce X(n)is:');
xlabel('---->n');
ylabel('---->X(n)');grid;
N=length(X);
for n=1:N
x(n)=0;
for k=1:N
x(n)=x(n)+X(k).*exp(j.*2.*pi.*(n-1).*(k-1)./N);
x(n)=x(n)./N;
end
end
disp('The IDFT of the i/p sequence X(n) is x(n):')
p=0:(N-1);
subplot(2,2,[3,4]), stem(p,abs(x));
title('The IDFT of the i/p sequence X(n) is x(n):');
xlabel('---->n');
ylabel('---->x(n)');grid;
disp(x);

CIRCULAR CONVOLUTION


2. CIRCULAR CONVOLUTION



AIM: To verify Circular Convolution.

EQUIPMENTS:
Software - MATLAB 7.5

Learning Objectives: To make the students familiar with concept of circular convolution
with the help of MATLAB.

THEORY:
Circular convolution is another way of finding the convolution sum of two input signals.
It resembles the linear convolution, except that the sample values of one of the input signals is
folded and right shifted before the convolution sum is found. Also note that circular convolution
could also be found by taking the DFT of the two input signals and finding the product of the
two frequency domain signals. The Inverse DFT of the product would give the output of the
signal in the time domain which is the circular convolution output. The two input signals could
have been of varying sample lengths. But we take the DFT of higher point, which ever signals
levels to. For eg. If one of the signal is of length 256 and the other spans 51 samples, then we
could only take 256 point DFT. So the output of IDFT would be containing 256 samples instead
of 306 samples, which follows N1+N2 – 1 where N1 & N2 are the lengths 256 and 51
respectively of the two inputs. Thus the output which should have been 306 samples long is
fitted into 256 samples. The 256 points end up being a distorted version of the correct signal.
This process is called circular convolution.

PROGRAM:
%circular convolution program:
clc;
clear all;
close all;
disp('circular convolution program');
x=input('enter i/p sequence x(n):');
a=length(x);
disp(a);
h=input('enter i/p sequence h(n):');
b=length(h);
disp(b);
subplot(2,2,1), stem(x);
title('i/p sequence x(n)is:');
xlabel('---->n');
ylabel('---->x(n)');grid;
subplot(2,2,2), stem(h);
title('i/p sequence h(n)is:');
xlabel('---->n');
ylabel('---->h(n)');grid minor;
disp('circular convolution of x(n) & h(n) is y(n):');
if(a>b)
n=a;


 else
n=b;
end
if(a-b~=0)
if(a>b)
h=[h,zeros(1,a-b)];
else
x=[x,zeros(1,b-a)];
end
end
disp(x);
disp(h);
y=zeros(1,n);
for i=1:n
y(i)=0;
k=i;
for j=1:n
y(i)=y(i)+(x(j)*h(k));
if k==1
k=n+1;
end
k=k-1;
end
end
subplot(2,2,[3,4]),stem(y);
title('circular convolution of x(n) & h(n) is:');
xlabel('---->n');
ylabel('---->y(n)');grid;
disp(y);

Top 10 Electronics Experiment in Mid- Engineering.


Top 10 Electronics Experiment in Mid- Engineering.

1.
To develop program for linear convolution and correlation using MATLAB.
2.
To develop a program for computing circular convolution Using MATLAB.
3.
To develop a program for computing DFT and IDFT using MATLAB.
4.
To develop a program for computing inverse Z-transform using MATLAB.
5.
To develop a program for designing FIR Filter in MATLAB.
6.
To develop a program for designing IIR Filters in MATLAB.
7.
To generate a FM Signal and measure Depth of modulation.
8.
To obtain Amplitude modulated envelope and determine depth of modulation
9.
To study envelope detector for demodulation of AM signal and observe diagonal peak clipping effect.
10.
Design Hartley oscillator and determine lowest and highest frequency it can generate.
11.
Design and observe waveforms of colpitt’s oscillator, compare its characteristics with Hartley oscillator.
12.
Design RC phase shift oscillator and determine lowest and highest frequency it can generate.