From rbrooks@charcoal.eg.bucknell.edu Thu Sep 18 11:26 EDT 1997
Date: Thu, 18 Sep 1997 11:25:59 -0400
From: rbrooks@charcoal.eg.bucknell.edu (Brooks Robert Austin '99)

% Part f:  y[n] = 0.1y^2[n-1] + x[n]


n = 0:10;

% 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.1*y1(i-1)^2 + x;
end

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


% Part b: x[n] = u[n], output y2[n]

x = 2;
y2(1) = x;

for i=2:11
  x = 2;
  y2(i) = 0.1*y2(i-1)^2 + x;
end

figure(2)
stem(n, y2)
title('Problem 1.34 (f.b)')
xlabel('Time index (n)')
ylabel('y2[n]')


% Part c: x[n] = sin(pi*n/4)*u[n]

x = sin(pi/4);
y3(1) = x;

for i=2:11
  x = sin(pi*i/4);
  y3(i) = 0.1*y3(i-1)^2 + x;
end

figure(3)
stem(n, y3)
title('Problem 1.34 (f.c)')
xlabel('Time index (n)')
ylabel('y3[n]')


% Part d: x[n] = 2*u[n] + sin(pi*n/4)*u[n]

x = 2 + sin(pi/4);
y4(1) = x;

for i=2:11
  x = 2 + sin(pi*i/4);
  y4(i) = 0.1*y4(i-1)^2 + x;
end

figure(4)
stem(n, y4)
title('Problem 1.34 (f.d)')
xlabel('Time index (n)')
ylabel('y4[n]')


