discrete fixed point and their stability
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Walter Roberson
el 5 de Nov. de 2023
Movida: Walter Roberson
el 5 de Nov. de 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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!