Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

How to simulate basic markov chain

Asked by John on 12 Oct 2012

Hi,

I'm fairly new to matlab. Would anybody be able to show me how I would simulate a basic discrete time markov chain?

Say for example I have a transition matrix with 3 states, A, b and C, how could I simulate say 20 steps starting from state A?

    A   B  C
  A .3 .2. .5
  B .2 .1. .7
  C .1 . 5 .4

Any help would be greatly appreciated.

Regards

John

0 Comments

John

Products

No products are associated with this question.

1 Answer

Answer by Doug Hull on 12 Oct 2012
Edited by Doug Hull on 12 Oct 2012

Are you looking to do a simple matrix multiply?

v = [1 0 0]
m = [0.3 0.2 0.5; 0.2 0.1 0.7; 0.1 0.5 0.4]
v = v * m

You can also do this in a loop.

If you want to square the matrix element by element

m = m.^2

but more likely you wish to square the matrix

m = m^2

You can do this for higher powers:

m = m^20

And putting it together:

    >> v = v*m^20
v =
      0.1652    0.3217    0.5130

0 Comments

Doug Hull

Contact us