From kozick@charcoal.eg.bucknell.edu Mon Sep 15 14:04 EDT 1997 Date: Mon, 15 Sep 1997 14:03:31 -0400 From: Kozick Rich To: gamache@bucknell.edu, louie@bucknell.edu, dkline@bucknell.edu, rbrooks@bucknell.edu, vary@bucknell.edu, dseiler@bucknell.edu, suqi@bucknell.edu, reed@bucknell.edu, mwtaylor@bucknell.edu, keeney@bucknell.edu, mmccrthy@bucknell.edu, blixt@bucknell.edu, sgordon@bucknell.edu, pankake@bucknell.edu, ganiear@bucknell.edu, campbell@bucknell.edu, michael@bucknell.edu, jcarey@bucknell.edu, pickert@bucknell.edu, sweet@bucknell.edu, bixby@bucknell.edu, eneff@bucknell.edu, vallone@bucknell.edu, hajdu@bucknell.edu, kmehaffy@bucknell.edu, pribik@bucknell.edu, ligong@bucknell.edu, kozick@bucknell.edu Subject: Sample for HW 8 Hi, To help you with the MATLAB program for Homework 8 in ELEC 320, I have provided a sample program for part (a) of problem 1.34. The program is available at http://www.eg.bucknell.edu/~kozick/elec320/hw8s.m It is also linked to the "Homework" section of the course home page. The program hw8s.m is also attached to this email message. Thank you. Rich Kozick % ================= % Sample MATLAB program for Homework 8: Problem 1.34 in the Kamen/Heck text. % % ELEC 320, Fall 1997, Rich Kozick % NOTE: MATLAB does not allow an index of zero in vectors. % Thus the array index will be one greater than the time index. % In other words, the discrete-time signal value y[n] will be % stored at array location y[n+1]. % Parts a-e: y[n] = 0.5*y[n-1] + x[n], n = 0, 1, ..., 10 % with initial condition y[-1] = 0. n = 0:10; % Vector of times at which we will evaluate system output. % This will be used for plotting. % Part a: x[n] = u[n], output y1[n] x = 1; y1(1) = x; % Do time n=0 separately to handle initial condition. for i=2:11 % Compute system outputs for times 1, 2, ..., 10 x = 1; y1(i) = 0.5*y1(i-1) + x; end figure(1) % Plot output signal y1[n] stem(n, y1) title('Problem 1.34 (a)') xlabel('Time index (n)') ylabel('y1[n]')