Write a Program to compute the N-point DFT of a sequence. Don't use the inbuilt command. Write your own routine of DFT.
clc;
close all;
clear all;
n = 0:1/100:100; % Time vector
x= 2*cos(2*pi*n/10) + cos(2*pi*n/5) ;
N = 200;
y = fft(x,N);
m = abs(y);
p = angle(y);
f = (0:length(y)-1)*100/length(y);
subplot(2,1,1)
plot(f,m)
title('Magnitude')
subplot(2,1,2)
plot(f,p*180/pi)
title('Phase')
figure;
subplot(2,1,1)
stem(f,m)
title('Magnitude')
subplot(2,1,2)
stem(f,p*180/pi)
title('Phase')
Comments
Leave a comment