clc;
clear all;
close all;
x=input('enter the input sequence');
L=length(x);
N=input('enter number of samples');
xn=[x zeros(1,N-L)]
n=[0:1:N-1]
k=[0:1:N-1]
wN=exp(-j*2*pi/N);
nk=n'*k;
wNnk=wN.^(nk);
xk=xn*wNnk;
disp('dft of given sequence');
disp(xk);
figure(1);
subplot(2,1,1);
stem(k,xn);
title('original samples');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,xk);
title('discrete fourier transform');
xlabel('samples');
ylabel('amplitude');
figure(2)
subplot(2,1,1);
stem(k,abs(xk));
title('magnitude response');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,angle(xk));
title('phase response');
xlabel('frequency');
ylabel('amplitude');
% IDFT
clc;
clear all;
close all;
x=input('enter the input sequence');
L=length(x);
N=input('enter number of samples');
xk=[x zeros(1,N-L)]
n=[0:1:N-1]
k=[0:1:N-1]
wN=exp(-j*2*pi/N);
nk=n'*k;
wNnk=wN.^(-nk);
xn=(xk*wNnk)/N;
disp('dft of given sequence');
disp(xk);
figure(1);
subplot(2,1,1);
stem(k,xk);
title('original samples');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,xn);
title('discrete fourier transform');
xlabel('samples');
ylabel('amplitude');
clear all;
close all;
x=input('enter the input sequence');
L=length(x);
N=input('enter number of samples');
xn=[x zeros(1,N-L)]
n=[0:1:N-1]
k=[0:1:N-1]
wN=exp(-j*2*pi/N);
nk=n'*k;
wNnk=wN.^(nk);
xk=xn*wNnk;
disp('dft of given sequence');
disp(xk);
figure(1);
subplot(2,1,1);
stem(k,xn);
title('original samples');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,xk);
title('discrete fourier transform');
xlabel('samples');
ylabel('amplitude');
figure(2)
subplot(2,1,1);
stem(k,abs(xk));
title('magnitude response');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,angle(xk));
title('phase response');
xlabel('frequency');
ylabel('amplitude');
% IDFT
clc;
clear all;
close all;
x=input('enter the input sequence');
L=length(x);
N=input('enter number of samples');
xk=[x zeros(1,N-L)]
n=[0:1:N-1]
k=[0:1:N-1]
wN=exp(-j*2*pi/N);
nk=n'*k;
wNnk=wN.^(-nk);
xn=(xk*wNnk)/N;
disp('dft of given sequence');
disp(xk);
figure(1);
subplot(2,1,1);
stem(k,xk);
title('original samples');
xlabel('samples');
ylabel('amplitude');
subplot(2,1,2);
stem(k,xn);
title('discrete fourier transform');
xlabel('samples');
ylabel('amplitude');
0 comments:
Post a Comment