function w = Update(P,v)
% Update state vector v given transition probability matrix P.
% Return and display updated state vector w.
% P is an n-by-n array of transition probabilities
% v is an n-by-1 state vector

n = length(v);
w = zeros(n,1);
for i=1:n
   % Compute the ith component of the new state vector..
   for j=1:n
      w(i) = w(i) + P(i,j)*v(j);
   end
   fprintf('%6.0f', w(i))
end
fprintf('\n')
