-
Notifications
You must be signed in to change notification settings - Fork 1
/
question2.m
36 lines (32 loc) · 1.09 KB
/
question2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
%% Lab 2: 2019862s
% Question 2
% Find the dominant eigenvalue (growth rate) and
% the right eigenvector (stable age distribution).
A=[ 0, 0, 0, 0, 127, 4, 80;...
0.67, 0.74, 0, 0, 0, 0, 0;...
0, 0.05, 0.66, 0, 0, 0, 0;...
0, 0, 0.015, 0.69, 0, 0, 0;...
0, 0, 0, 0.052, 0, 0, 0;...
0, 0, 0, 0, 0.81, 0, 0;...
0, 0, 0, 0, 0, 0.81, 0.81];
% Show the eigenvectors with corresponding eigenvalues
[V,D]=eig(A);
% Store all eigenvalues from the diagonal matrix
L=diag(D);
% The position of the dominant eigenvalue
j=find(abs(L)==max(abs(L)));
% Ensure there is a unique dominant eigenvalue
ndom=length(L);
% Display the eigenvalue
lambda=L(j);
disp(lambda);
% Stable age distirbution
v=V(:,j);
disp(v);
% Uncomment code below to estimate the
% stable age distirbution at time t.
% % Set value for time we are interested in
% t = 40;
% % Approximate the population using Equation (2)
% Ntime=lambda^(t)*v;
% disp(Ntime);