summaryrefslogtreecommitdiff
path: root/22/CH8/EX8.9/ch8ex9.sce
blob: 161d190e93870ae40d33524906c89e44071a585f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//signals and systems
//sampling:the bridge from continuous to discrete
//DFT to compute the fourier transform of 8rect(t)
T_0 = 4;
N_0 = 32;
T = T_0/N_0;
x_n = [ones(1,4) 0.5 zeros(1,23) 0.5 ones(1,3)]';
size(x_n)
x_r = fft(x_n);r = (-N_0/2:(N_0/2)-1)';
omega_r = ((r*2)*%pi)/T_0;
size(omega_r)
size(omega)
omega = linspace(-%pi/T,%pi/T,4097);
X = 8*(sinc(omega/2));
size(X)
figure(1);
subplot(2,1,1);
plot(omega,abs(X),"k");
plot(omega_r,fftshift(abs(x_r)),"ko")
xtitle("angle of X(omega) for true FT and DFT");
a=gca();
subplot(2,1,2);
a = gca();
a.y_location ="origin";
a.x_location ="origin";
plot(omega,atan(imag(X),real(X)),"k",omega_r,fftshift(atan(imag(x_r),real(x_r))),'r.');
xtitle("angle of X(omega) for true FT and DFT");