discrete fixed point and their stability
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
What is the rong with my code?
there is an error message "Conversion to logical from sym is not possible."
clc;
clear all;
syms xn xe
assume(0<xn<=1)
r=input('Enter the value of production rate','s')
f(xn)=r*xn*(1-xn);
eq=xe==subs(f,xn,xe)
display('The equilibrium points are:')
xe=solve(eq)
df=diff(r*xn*(1-xn),xn)
eq1=subs(df,xn,xe);
t=length(eq1);
eq1=double(eq1);
for i=1:t
if eq(i)>1;
fprintf('The equilibrium point %g is unstable',eq(i))
elseif eq(i)<-1;
fprintf('The equilibrium point %g is unstable',eq(i))
elseif 0<eq(i)&&eq(i)<1
fprintf('The equilibrium point %g is stable',eq(i))
else -1<eq(i)&&eq(i)<0
fprintf('The equilibrium point %g is stable',eq(i))
end
end
0 Kommentare
Antworten (2)
Walter Roberson
am 5 Nov. 2023
Verschoben: Walter Roberson
am 5 Nov. 2023
for r = -2:0.25:5
syms xn xe
assume(0<xn<=1)
f(xn)=r*xn*(1-xn);
eq=xe==subs(f,xn,xe);
fprintf('r = %g, The equilibrium points are:\n', r)
xe=solve(eq);
disp(char(xe))
df = diff(r*xn*(1-xn),xn);
eq1 = simplify(subs(df,xn,xe));
t = length(eq1);
eq1 = double(eq1);
for i=1:t
if eq1(i)>1
fprintf('r = %g, The equilibrium point %g is unstable',r,eq1(i));
elseif eq1(i)<-1
fprintf('r = %g, The equilibrium point %g is unstable',r,eq1(i));
elseif 0<eq1(i)&&eq1(i)<1
fprintf('r = %g, The equilibrium point %g is stable',r,eq1(i));
elseif -1<eq1(i)&&eq1(i)<0
fprintf('r = %g, The equilibrium point %g is stable',r,eq1(i));
else
fprintf('r = %g, failed to classify %g\n', r, eq1(i));
end
end
fprintf('\n-----\n');
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!