I am given a 3x3 matrix [0.4, 0.1, 0.2; 0.3, 0.7. 0.7; 0.3, 0.2, 0.1]. The question is to find the steady state vector. However, I am supposed to solve it using Matlab and I am having trouble getting the correct answer. We are supposed to use the formula A(x-I)=0. I can solve it by hand, but I am not sure how to input it into Matlab. Any help is greatly appreciated.
1 Answers
1
votes
I'm going to assume you meant x(A-I)=0
since what you wrote doesn't really make sense to me. The equation I wrote implies that x*A^n=x
which is what is usually meant by steady state. The solution to the equation is the left eigenvector of A
with eigenvalue of 1
.
You can get the eigenvectors and eigenvalues of A
using the eig
function.
A = [0.4, 0.1, 0.2; 0.3, 0.7, 0.7; 0.3, 0.2, 0.1];
% Get the eigenvalues (D) and left eigenvectors (W)
[~,D,W] = eig(A);
% Get the index of the eigenvalue closest to 1
[~,idx] = min(abs(diag(D)-1));
% Get associated eigenvector
x = W(:,idx).';
Checking the solution
>> all(abs(x*(A-eye(size(A)))) < 1e-10)
ans =
logical
1