%% Specify Starting States for Multiple Simulations
% Create a four-state Markov chain from a randomly generated transition matrix containing eight infeasible transitions.

rng('default'); % For reproducibility 
mc = mcmix(4,'Zeros',8);

% mc is a dtmc object.
%
% Plot a digraph of the Markov chain.

figure;
graphplot(mc);

% State 4 is an absorbing state.
%
% Run three 10-step simulations for each state.

x0 = 3*ones(1,mc.NumStates);
numSteps = 10;
X = simulate(mc,numSteps,'X0',x0);

% X is an 11-by-12 matrix. Rows corresponds to steps in the random walk. Columns 1–3 are the simulations that start at state 1; column 4–6 are the simulations that start at state 2; columns 7–9 are the simulations that start at state 3; and columns 10–12 are the simulations that start at state 4.
%
% For each time, plot the proportions states that are visited over all simulations.

figure;
simplot(mc,X)

% Copyright 2012 The MathWorks, Inc.