want to see where is the problem in this code doesn't give me result

2 Ansichten (letzte 30 Tage)
Ahmad
Ahmad am 10 Mär. 2023
Kommentiert: Image Analyst am 11 Mär. 2023
function J = system_model_jacobian(x,y,z,k,a1,a2,b2,c,d,p,sigma,beta)
J = [p*(1-x/k)-a1*y, -a1*x+c*a1*y/(b2+y)-d, 0; a2*y*z/(b2+y)^2, c*a1*x*z/(b2+y)^2-d, -beta*z^2/(b2+y)+2*sigma*z; 0, 0, 0];
% Compute Jacobian matrix at the steady states
x1 = [0, 0, 0];
x2 = [k, 0, 0];
x3 = [d/(c*a1), p*b1/(c*k*a1^2), 0];
x4 = [(k*(sigma*p-a1*b2))/(p*sigma), p*b1/(c*k*a1^2), beta*(p*sigma*b1-c*a1^2*b2)/(a2*p*sigma^2)];
J1 = subs(J,{x,y,z},{x1(1),x1(2),x1(3)});
J2 = subs(J,{x,y,z},{x2(1),x2(2),x2(3)});
J3 = subs(J,{x,y,z},{x3(1),x3(2),x3(3)});
J4 = subs(J,{x,y,z},{x4(1),x4(2),x4(3)});
% Compute eigenvalues of each steady state
lambda1 = eig(J1);
lambda2 = eig(J2);
lambda3 = eig(J3);
lambda4 = eig(J4);
% Display results
disp('Steady State 1:');
disp(['Eigenvalues: ', num2str(lambda1(1)), ', ', num2str(lambda1(2)), ', ', num2str(lambda1(3))]);
disp('Steady State 2:');
disp(['Eigenvalues: ', num2str(lambda2(1)), ', ', num2str(lambda2(2)), ', ', num2str(lambda2(3))]);
disp('Steady State 3:');
disp(['Eigenvalues: ', num2str(lambda3(1)), ', ', num2str(lambda3(2)), ', ', num2str(lambda3(3))]);
disp('Steady State 4:');
disp(['Eigenvalues: ', num2str(lambda4(1)), ', ', num2str(lambda4(2)), ', ', num2str(lambda4(3))]);
end
  3 Kommentare
Rik
Rik am 10 Mär. 2023
This is perhaps related to the previous question, but that context might not be that helpful.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 10 Mär. 2023
What did you pass in for x,y,z,k,a1,a2,b2,c,d,p,sigma,beta? You didn't just click the green run triangle, did you? Because doing that will not "invent" values to pass in for you.
What do you mean by "give me result"? Did you mean it doesn't give you any result at all? Or did you mean it gave you a result, but not the result you expected?
  6 Kommentare
Image Analyst
Image Analyst am 11 Mär. 2023
You have to assign them to something, so your test script would be something like this
x = 1
y = 2
z = 3
k=42
a1=9
a2=5
b2=6
c=99
d=234234
p=4234
sigma=234
beta=0.5
J = system_model_jacobian(x,y,z,k,a1,a2,b2,c,d,p,sigma,beta)

Melden Sie sich an, um zu kommentieren.

Kategorien

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by