summaryrefslogtreecommitdiff
path: root/716/CH9/EX9.3.V/9_13_ExerciseV9_3.sce
blob: 492d4b7ee20386008ac02de6c4c591e63e5cb42b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//Perform DFT of x(n)=(1 1 1 2 2) and sketch magnitude and phase spectrum
clc;
clear;
N=5;
xn=[1 1 1 2 2];
for k=0:1:N-1
    Xk(k+1)=0;
    for n=0:1:N-1
        Xk(k+1)=Xk(k+1)+xn(n+1)*exp(-%i*2*%pi*k*n/N);
    end
end
wk=0:1:N-1;
disp(Xk,'4 point DFT of x(n)=>');
disp(abs(Xk),'magnitude of 4 point DFT x(n)=>');
disp(atan(imag(Xk),real(Xk)),'phase of 4 point DFT x(n)=>');
subplot(1,2,1)
plot2d3(wk,abs(Xk),2);
xtitle('Magnitude Spectrum','k','|X(k)|');
subplot(1,2,2)
plot2d3(wk,atan(imag(Xk),real(Xk)),2);
xtitle('Phase Spectrum','k','angle(X(k))');