No BSD License  

Highlights from
Signals & Systems: Continuous and Discrete, 4e Companion Software

from Signals & Systems: Continuous and Discrete, 4e Companion Software by Rodger Ziemer
Companion Software for Signals & Systems: Continuous and Discrete, 4e

c10ex1.m
%	Plots of errors in computing the DFT - Example 10-1
%
clf
T = input('Enter the time window width ');
Tss = input('Enter the largest time sampling interval ');
for k = 1:3
k_even = 2*k;
k_odd = 2*k-1;
Ts = Tss/(2^(k-1));
fs = 1/Ts;
tn = -T/2:Ts:T/2;
L_t = length(tn);
del_f = 1/T;
f_max = (L_t - 1)*del_f;
fn = 0:del_f:f_max;
L_fn = length(fn);
f = 0:.01:f_max;
L_f = length(f);
X = fs*2./(1+(2*pi*f).^2);
L_X = length(X);
xs = exp(-abs(tn));
L_xs = length(xs);
Xs = fft(xs);
L_Xs = length(Xs);
subplot(4,2,k_odd), stem(tn, xs), xlabel('tn'), ylabel('x(tn)'),...
axis([-T/2 T/2+.01 0 1]),...
if k == 1
	title(['FFT pairs for double-sided exponential; T = ', num2str(T)])
end
subplot(4,2,k_even), stem(fn, abs(Xs)), xlabel('fk, f'),...
	ylabel('X(fk), X(f)'),axis([ 0 f_max 0 2^k+.2]),hold
subplot(4,2,k_even), plot(f, X)
end

Contact us at files@mathworks.com