function y=state_vs_time(P,s0,n,step) 
%STATE_VS_TIME finds state vector time development
%The program accepts a Markov matrix 
%and finds the time progression
%of a given initial state vector.
%The output of the program is a matrix whose columns 
%are the state vector values at different 
%time steps that are specified by the user.
%P=state matrix
%s0=initial state vector (column vector)
%n=number of iterations desired
%step = increment of time step
state_size = size(s0);
if state_size(1)==1
   s0 = s0'; %turn s into a column vector
end

m = size(P,1); %determine the number of rows. 
S = zeros(m,n); 
S(:,1) = s0;
time = 0;
for i=2:n
   time = time+step;
   S(:,i)=P*S(:,i-1);
end
y=S;
