% Example 4-21 - illustration of the FFT and inverse FFT
% by taking the FFT of a square pulse of various widths
%
T = 4;
del_t = .2;
t = 0:del_t:T;
L_t = length(t);
del_f = 1/T;
f_max = (L_t-1)*del_f;
f = 0:del_f:f_max;
for k = 1:3
width = k*0.6;
k_1 = 3*(k-1)+1;
k_2 = 3*k-1;
k_3 = 3*k;
x = pls_fn((t - width/2)/width);
X = fft(x);
X_inv = ifft(X);
subplot(3,3,k_1), stem(t,x), axis([0 T 0 1]),...
xlabel('t'), ylabel('x(t)')
subplot(3,3,k_2), stem(f,abs(X)), axis([0 f_max 0 10]),...
xlabel('f'), ylabel('X(f)')
subplot(3,3,k_3), stem(t,abs(X_inv)), axis([0 T 0 1]),...
xlabel('t'), ylabel('X_inv(t)')
end