discrete fixed point and their stability

6 visualizaciones (últimos 30 días)
Nehad
Nehad el 5 de Nov. de 2023
Movida: Walter Roberson el 5 de Nov. de 2023
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

Respuestas (2)

madhan ravi
madhan ravi el 5 de Nov. de 2023
eq1(i)

Walter Roberson
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
r = -2, The equilibrium points are:
[0; 3/2]
r = -2, The equilibrium point -2 is unstable
r = -2, The equilibrium point 4 is unstable
-----
r = -1.75, The equilibrium points are:
[0; 11/7]
r = -1.75, The equilibrium point -1.75 is unstable
r = -1.75, The equilibrium point 3.75 is unstable
-----
r = -1.5, The equilibrium points are:
[0; 5/3]
r = -1.5, The equilibrium point -1.5 is unstable
r = -1.5, The equilibrium point 3.5 is unstable
-----
r = -1.25, The equilibrium points are:
[0; 9/5]
r = -1.25, The equilibrium point -1.25 is unstable
r = -1.25, The equilibrium point 3.25 is unstable
-----
r = -1, The equilibrium points are:
[0; 2]
r = -1, failed to classify -1
r = -1, The equilibrium point 3 is unstable
-----
r = -0.75, The equilibrium points are:
[0; 7/3]
r = -0.75, The equilibrium point -0.75 is stable
r = -0.75, The equilibrium point 2.75 is unstable
-----
r = -0.5, The equilibrium points are:
[0; 3]
r = -0.5, The equilibrium point -0.5 is stable
r = -0.5, The equilibrium point 2.5 is unstable
-----
r = -0.25, The equilibrium points are:
[0; 5]
r = -0.25, The equilibrium point -0.25 is stable
r = -0.25, The equilibrium point 2.25 is unstable
-----
r = 0, The equilibrium points are:
0
r = 0, failed to classify 0
-----
r = 0.25, The equilibrium points are:
[-3; 0]
r = 0.25, The equilibrium point 1.75 is unstable
r = 0.25, The equilibrium point 0.25 is stable
-----
r = 0.5, The equilibrium points are:
[-1; 0]
r = 0.5, The equilibrium point 1.5 is unstable
r = 0.5, The equilibrium point 0.5 is stable
-----
r = 0.75, The equilibrium points are:
[-1/3; 0]
r = 0.75, The equilibrium point 1.25 is unstable
r = 0.75, The equilibrium point 0.75 is stable
-----
r = 1, The equilibrium points are:
[0; 0]
r = 1, failed to classify 1 r = 1, failed to classify 1
-----
r = 1.25, The equilibrium points are:
[0; 1/5]
r = 1.25, The equilibrium point 1.25 is unstable
r = 1.25, The equilibrium point 0.75 is stable
-----
r = 1.5, The equilibrium points are:
[0; 1/3]
r = 1.5, The equilibrium point 1.5 is unstable
r = 1.5, The equilibrium point 0.5 is stable
-----
r = 1.75, The equilibrium points are:
[0; 3/7]
r = 1.75, The equilibrium point 1.75 is unstable
r = 1.75, The equilibrium point 0.25 is stable
-----
r = 2, The equilibrium points are:
[0; 1/2]
r = 2, The equilibrium point 2 is unstable
r = 2, failed to classify 0
-----
r = 2.25, The equilibrium points are:
[0; 5/9]
r = 2.25, The equilibrium point 2.25 is unstable
r = 2.25, The equilibrium point -0.25 is stable
-----
r = 2.5, The equilibrium points are:
[0; 3/5]
r = 2.5, The equilibrium point 2.5 is unstable
r = 2.5, The equilibrium point -0.5 is stable
-----
r = 2.75, The equilibrium points are:
[0; 7/11]
r = 2.75, The equilibrium point 2.75 is unstable
r = 2.75, The equilibrium point -0.75 is stable
-----
r = 3, The equilibrium points are:
[0; 2/3]
r = 3, The equilibrium point 3 is unstable
r = 3, failed to classify -1
-----
r = 3.25, The equilibrium points are:
[0; 9/13]
r = 3.25, The equilibrium point 3.25 is unstable
r = 3.25, The equilibrium point -1.25 is unstable
-----
r = 3.5, The equilibrium points are:
[0; 5/7]
r = 3.5, The equilibrium point 3.5 is unstable
r = 3.5, The equilibrium point -1.5 is unstable
-----
r = 3.75, The equilibrium points are:
[0; 11/15]
r = 3.75, The equilibrium point 3.75 is unstable
r = 3.75, The equilibrium point -1.75 is unstable
-----
r = 4, The equilibrium points are:
[0; 3/4]
r = 4, The equilibrium point 4 is unstable
r = 4, The equilibrium point -2 is unstable
-----
r = 4.25, The equilibrium points are:
[0; 13/17]
r = 4.25, The equilibrium point 4.25 is unstable
r = 4.25, The equilibrium point -2.25 is unstable
-----
r = 4.5, The equilibrium points are:
[0; 7/9]
r = 4.5, The equilibrium point 4.5 is unstable
r = 4.5, The equilibrium point -2.5 is unstable
-----
r = 4.75, The equilibrium points are:
[0; 15/19]
r = 4.75, The equilibrium point 4.75 is unstable
r = 4.75, The equilibrium point -2.75 is unstable
-----
r = 5, The equilibrium points are:
[0; 4/5]
r = 5, The equilibrium point 5 is unstable
r = 5, The equilibrium point -3 is unstable
-----

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by