From bixby@charcoal.eg.bucknell.edu Wed Sep 17 00:54 EDT 1997
Date: Wed, 17 Sep 1997 00:54:20 -0400
From: bixby@charcoal.eg.bucknell.edu (Bixby Stephen Jones '99)

yinit = 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]
% part b: x[n] = 2*u[n], output y2[n]
% part c: x[n] = sin(pi*n/4)*u[n], output y3[n]
% part d: x[n] = 2*u[n] + sin(pi*n/4)*u[n], output y4[n]

x =1;
y1 (1) = 0.1*yinit^2 + x;    % Do time n=0 separately to handle initial condition.
y2 (1) = 0.1*yinit^2 + 2*x;  % Do time n=0 separately to handle initial condition.
y3 (1) = 0.1*yinit^2 + sin(pi*x/4)*x;
y4 (1) = 0.1*yinit^2 + 2*x + sin(pi*x/4)*x;
    

for i=2:11      % Compute system outputs for times 1,2,...,10
  x = 1;
  y1 (i) = 0.1*y1(i-1)^2 + x;
  y2 (i) = 0.1*y2(i-1)^2 + 2*x;
  y3 (i) = 0.1*y3(i-1)^2 + sin(pi*x/4)*x;
  y4 (i) = 0.1*y4(i-1)^2 + 2*x + sin(pi*x/4)*x;
  
end


figure(1)      % Plot output signal y1[n]
stem (n, y1)
title ('Problem 1.34 (a)')
xlabel ('Time index (n)')
ylabel ('y1[n]')

figure(2)      % Plot output signal y2[n]
stem (n, y2)
title ('Problem 1.34 (b)')
xlabel ('Time index (n)')
ylabel ('y2[n]')

figure(3)      % Plot output signal y3[n]
stem (n, y3)
title ('Problem 1.34 (c)')
xlabel ('Time index (n)')
ylabel ('y3[n]')

figure(4)      % Plot output signal y4[n]
stem (n, y4)
title ('Problem 1.34 (d)')
xlabel ('Time index (n)')
ylabel ('y4[n]')


