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!