DSP Exp4 2001ee24
DSP Exp4 2001ee24
DSP LAB
EXPERIMENT 04
x = [0,1,2,3];
N = length(x);
for a=1:N
for j=1:N
power = (2*i*pi*(a-1)*(j-1))/N;
mat(a, j) = exp(power);
end
end
% DFT answer
Xd = x*mat;
disp(Xd);
% IDFT answer
matInv = inv(mat);
IXd = Xd*matInv;
disp(IXd);
Aim 3: Consider Aim 1 and Aim 2 and write "C" program to verify using Code Composer
Studio (CCS-3.1) IDE and the DSP TMS 320C6713 DSK Kit.
CCS Code: -
#include<math.h>
Aim 4: To find N point FFT and IFFT of the given sequence (Decimation in time and
decimation in frequency algorithms) without using the MATLAB inbuilt functions. Plot and
check your results with the inbuilt functions.
MATLAB Code for FFT: -
clc
close all
clear all
x =[0,1,2,3];
n = length(x);
xa= [0:n-1];
[ll,aa] = bitrevorder(xa);
xx = zeros(1, n);
for ii=1:n
xx(ii) = x(aa(ii));
end
Xdf =xx;
dum = zeros(1, n);
Wn = exp(-i*2*pi/n);
stage = log(n)/log(2);
size = 2;
for e= 1: stage
steps = n/size;
jj = 1;
for b = 1: steps
for i = 1: size
power = Wn.^((i-1)*steps);
p = size/2;
ind = jj-1;
ind = rem(ind, p);
ind = ind+1;
ind = ind + (b-1)*size;
dum(jj) = Xdf(ind) + power*Xdf(ind + p);
jj = jj +1;
end
end
for i = 1:n
Xdf(i) = dum(i);
end
size = size*2;
end
disp(Xdf);
% Comparing ans
fft(x)
clc
close all;
clear all;
for ii=1:n
xx(ii) = x(aa(ii));
end
Xdf =xx;
dum = zeros(1, n);
Wn = exp(i*2*pi/n);
stage = log(n)/log(2);
size = 2;
for e= 1: stage
steps = n/size;
jj = 1;
for b = 1: steps
for i = 1: size
power = Wn.^((i-1)*steps);
p = size/2;
ind = jj-1;
ind = rem(ind, p);
ind +=1;
ind +=(b-1)*size;
dum(jj) = Xdf(ind) + power*Xdf(ind + p);
jj +=1;
end
end
for i = 1: n
Xdf(i) = dum(i);
end
size = size*2;
end
for i=1: n
Xdf(i) = Xdf(i)/n;
end
disp(Xdf);
% Comparing ans
fft(x)
Aim 5: Consider Aim 4 and write "C" program to verify using Code Composer Studio (CCS-
3.1) IDE and the DSP TMS 320C6713 DSK Kit.
int main(){
int n = sizeof(xReal)/sizeof(xReal[0]);
float dumr[n], dumi[n];
float XdReal[n], XdImg[n];
int i=0;
int main(){
int n = sizeof(xReal)/sizeof(xReal[0]);
float dumr[n], dumi[n];
float XdReal[n], XdImg[n];
int i=0;