How to iterate fixed points values in order to print all eigenvalues in lokta-volterra model
2 次查看(过去 30 天)
显示 更早的评论
All I want is to be able to print on the console all possible eigenvalues from the fixed points obtained, without having to change P value manually.
This is what I have so far, and it works.
Thank you
function stationary()
g1 = 1.2;
g2 = 0.2;
g11 = 3;
g12 = 8;
g21 = 1;
g22 = 6;
%Fixed Points
syms x y
eqn1 = g1*(1-g11*x-g12*y)*x == 0;
eqn2 = -g2*(1-g21*x+g22*y)*y==0;
sol = solve([eqn1, eqn2], [x, y]);
xFP = sol.x;
yFP = sol.y;
%Jacobian matrix
F= [g1*(1-g11*x-g12*y)*x, g2*(1-g21*x+g22*y)*y];
V= [x y];
J=jacobian(F,V);
%Jacobian matrix evaluated in a specific fixed point
P= [1 1];%----->so far this is manual been all possible options [(0,0), (0,1), (1,0), (1,1)]
jnew=subs(J,V,P);
%Eigenvalues
Eig= eig(jnew);
disp(Eig)%------->I want to display all Eig with all posible fixed points (P)
%Plotting the equations
x = 0:10;
line1 = (1-g11*x)/g12;
line2 = (g21*x-1)/g22;
plot (x, line1, x, line2)
0 个评论
回答(1 个)
Shubh Sahu
2019-10-7
Hello Carlos,
Hope this will work for you
function stationary()
g1 = 1.2;
g2 = 0.2;
g11 = 3;
g12 = 8;
g21 = 1;
g22 = 6;
%Fixed Points
syms x y
eqn1 = g1*(1-g11*x-g12*y)*x == 0;
eqn2 = -g2*(1-g21*x+g22*y)*y==0;
sol = solve([eqn1, eqn2], [x, y]);
xFP = sol.x;
yFP = sol.y;
%Jacobian matrix
F= [g1*(1-g11*x-g12*y)*x, g2*(1-g21*x+g22*y)*y];
V= [x y];
J=jacobian(F,V);
%Jacobian matrix evaluated in a specific fixed point
for i=0:1
for j=0:1
P=[i j]; %----> possible options
jnew=subs(J,V,P);
Eig= eig(jnew);
disp(Eig);%------->displaying all Eig with all posible fixed points (P)
end
end
%Plotting the equations
x = 0:10;
line1 = (1-g11*x)/g12;
line2 = (g21*x-1)/g22;
plot (x, line1, x, line2)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!