Looping With Transition Matrices

조회 수: 4 (최근 30일)
Kiran
Kiran 2014년 1월 28일
댓글: Amit 2014년 1월 28일
Any help with this would be great. I have 2 Matrices, say A and B, which when multiplied make C. I then need to compare the elements of A and C like for like, choosing the largest to make Matrix D. D will then go through the same initial iterations as A until the value of D is unchanged when choosing the largest values.
I have used D=max(A,C) to find D, but I am finding it difficult to loop the process. I have also tried using tf=isequal(A,D), then while tf=0 to run the loop but to no avail.
Any help will be much appreciated.
  댓글 수: 1
AJ von Alt
AJ von Alt 2014년 1월 28일
Can we see what you have done so far? What part of constructing the loop are you having problems with?

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

답변 (1개)

Amit
Amit 2014년 1월 28일
I don't know the process you're doing on D to make it equal to A. However with floating points, there can be carry over like 1.0 and 1.0000001. Here even though 1.0000001 might be an artifact of the process and calculations, but is not equal to 1.0.
You can try
tol = 1e-6;
while (norm(A-D) < tol)
  댓글 수: 2
Kiran
Kiran 2014년 1월 28일
I am multiplying A, a matrix of probabilities by transition matrix B. Ideally I would need to multiply A by B for a single transition giving another matrix C. I need to compare the probabilities in A and C, choosing the highest in terms of like for like elements ie element A(1,1)=0.2 , C(1,1)=0.4 and so 0.4 is selected.
I need to repeat this process until the probabilities are indifferent.
Amit
Amit 2014년 1월 28일
Try the norm approach and see if it fixes it.

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by