0% found this document useful (0 votes)
16 views2 pages

DFT

Uploaded by

chetan kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

DFT

Uploaded by

chetan kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

clear all; close all; clc;

x1n = [1 2 3 4];
x2n = [8 2 5 6];
N = max(length(x1n),length(x2n));
X1k = fft(x1n,N);
X2k = fft(x2n,N);

subplot(2,2,1); stem(x1n);
xlabel('n'); ylabel('x1(n)'); title('signal x1(n)');
subplot(2,2,2); stem(x2n);
xlabel('n'); ylabel('x2(n)'); title('signal x2(n)');
subplot(2,2,3); stem(abs(X1k));
xlabel('k'); ylabel('X1(k)'); title('dft signal 1: X1(k)');
subplot(2,2,4); stem(abs(X2k));
xlabel('k'); ylabel('X2(k)'); title('dft signal 2: X2(k)');

A = 4; B = 5;
xin = A.*x1n + B.*x2n;
xout = fft(xin,N);
xout_ex = A.*X1k + B.*X2k;
disp('linearity property');
disp(['expected X(k): ', num2str(xout_ex)]);
disp(['calculated X(k): ', num2str(xout)]);

if(xout == xout_ex)
disp('linearity property is verified.');
else
disp('linearity property is verified.');
end

m = 1;
xin = circshift(x1n, m);
k = 0:N-1;
Wkm = exp(-j*2*pi*k*m/N);
xout_ex = Wkm.*X1k;
xout = fft(xin,N);

disp(' time shift property');


disp(['expected X(k): ', num2str(xout_ex)]);
disp(['calculated X(k): ', num2str(xout)]);

if(int8(xout_ex)==int8(xout))
disp('time shift property is verified.');
else
disp('time shift property is verified.);
end

xin = x1n.*x2n;
xout_ex = (1/N)*cconv(X1k,X2k,N);
xout = fft(xin,N);

disp('multiplication property');
disp(['expected X(k): ', num2str(xout_ex)]);
disp(['calculated X(k): ', num2str(xout)]);

if(int8(xout_ex)==int8(xout))
disp('multiplication property is verified.');
else
disp('multiplication property is not verified');
end

xin = cconv(x1n,x2n,N);
xout_ex = X1k.*X2k;
xout = fft(xin,N);

disp('convolution property');
disp(['expected X(k): ', num2str(xout_ex)]);
disp(['calculated X(k): ', num2str(xout)]);

if(int8(xout_ex)==int8(xout))
disp('convolution property is verified.');
else
disp('convolution property is not verified');
end

E_xin = x1n*x1n';
E_xout = (1/N).*X1k*X1k';
disp(' parsevals theorem');
disp(['energy in time domain ', num2str(E_xin)]);
disp(['energy in frequency domain: ', num2str(E_xout)]);

if(int8(E_xin)==int8(E_xout))
disp('parsevals theorem is verified.');
else
disp('parsevals theorem is not verified');
end

You might also like