plot states sequence over time

조회 수: 5 (최근 30일)
susman
susman 2021년 2월 23일
댓글: susman 2021년 3월 3일
I want to plot the state transitions chain of markov process. My original state transitions matrix is 56 by 1000. But here I give a small example
for example, if I have to plot this matrix, where each column represents discrete lifetime for one individual.
sequence = [1 1 1 1 2 2 2 2 2 3;...
1 1 1 1 1 1 1 1 1 1;...
1 1 1 1 1 1 1 1 1 1;...
1 1 1 1 1 1 1 2 2 2;...
1 1 1 1 1 1 1 1 1 1;...
2 2 2 2 2 2 2 2 2 2; ...
2 2 2 2 2 2 2 3 3 3; ...
2 3 3 3 3 3 2 2 2 2; ...
2 2 2 2 2 2 4 4 4 4]
age = (25:33)
How can I put on x axis the age variable and y axis the matrix sequence columnwise?

채택된 답변

Alan Moses
Alan Moses 2021년 2월 26일
You may use the following line of code:
plot(age,sequence(:,1:end))
To create labels for the lines plotted, you may use the legend function.
  댓글 수: 1
susman
susman 2021년 3월 3일
Thank you, that worked perfectly!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Markov Chain Models에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by