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

c4ex19.m
%	c4ex19
%
t_max = 2;
t = -t_max+1:.01:t_max;
L = length(t);
for k = 1:4				% Loop to do 4 values of window width
k_even = 2*k;
k_odd = 2*k - 1;
W = 2 + (k-1);
tp = [2*t(1):.01:2*t(L)];
w_r = 2*W*sinc(2*W*t);			% Inverse transform of rectangular window
w_h = W*(sinc(2*W*t)+.5*sinc(2*W*t-1)+.5*sinc(2*W*t+1));	% Hanning window
x = pls_fn(t-.5);
x_tilde_r = .01*conv(w_r, x);		% Convolve rectangular window with pulse
x_tilde_h = .01*conv(w_h, x);		% Convolve Hanning window with pulse
subplot(4,2,k_odd),plot(tp, x_tilde_r),xlabel('t'),ylabel('wind. x(t)'),...
	text(-.9,1,'rectan.'),text(-.9,.5, ['W = ',num2str(W)]),axis([-t_max+1 t_max -.2 1.5])
subplot(4,2,k_even),plot(tp, x_tilde_h),xlabel('t'),ylabel('wind. x(t)'),...
	text(-.9,1,'Hann.'),text(-.9,.5,['W = ',num2str(W)]),axis([-t_max+1 t_max -.2 1.5])
end

Contact us at files@mathworks.com