%% hw055
%
P = [ 0.75, 0.10, 0.05;
      0.15, 0.50, 0.35;
      0.10, 0.40, 0.60 ];

x = zeros(20,1);
y = zeros(20,1);
z = zeros(20,1);

for k = 1 : 20
  if ( k == 1 )
    x(1) = 700;
    y(1) = 300;
    z(1) =   0;
  else
    x(k) = P(1,1) * x(k-1) + P(1,2) * y(k-1) + P(1,3) * z(k-1);
    y(k) = P(2,1) * x(k-1) + P(2,2) * y(k-1) + P(2,3) * z(k-1);
    z(k) = P(3,1) * x(k-1) + P(3,2) * y(k-1) + P(3,3) * z(k-1);
  end
end

plot ( 1:20, x, 1:20, y, 1:20, z, 'Linewidth', 3 );
grid on
xlabel ( '<-- Years -->' );
ylabel ( '<-- Customers -->' );
title ( 'A, B, C Insurance customers', 'Fontsize', 24 );
legend ( 'A', 'B', 'C' );
print ( '-djpeg', 'hw055.jpg' ); 

