Using ODE45 to solve Rossler equations
21 次查看(过去 30 天)
显示 更早的评论
The Rossler equations are defined as
x'(t)=-x(t)-y(t)
y'(t)=ax(t)+y(t)
z'(t)=b+z(t)(x(t)-c)
and I am trying to use ode45 to solve them
I have so far created a ross function file
function dx = ross(t,x)
%ross: Computes the derivatives involved in solving the
%ross equations.
a=-0.1;
b=2;
c=5.7;
%Right hand sides
dx=zeros(3,1);
dx(1)=-1*x(1)-1*x(2);
dx(2)=a*x(1)+x(2);
dx(3)=b+(x(3)*(x(1)-c));
and I am trying the below code but it doesnt stop running and seems to be stuck in a loop
clear all
x0=[-8 8 27];
tspan=[0,20];
[t,x]=ode45(@ross,tspan,x0)
%or run
[t,x]=ode45(@lorenz,tspan,x0)
%BUT NOT BOTH IN THE SAME CODE (1 OR THE OTHER LORENZ OR ROSS)
plot3(x(:,1),x(:,2),x(:,3),'b','linewidth',1.5)
however if I have instead of @ross but have @lorenz
[t,x]=ode45(@lorenz,tspan,x0)
and try
function dx = lorenz(t,x)
% Parameters
sigma=10;
beta=8/3;
rho=28;
% Differential Equations
dx=zeros(3,1);
dx(1)=sigma*(x(2)-x(1));
dx(2)=rho*x(1)-x(2)-x(1)*x(3);
dx(3)=x(1)*x(2)-beta*x(3);
it seems to work fine, my question is where am I going wrong with my ross equations
回答(2 个)
Tanggo Tang
2021-3-29
Hi you have err in ross attraction
function dx = ross(t,x)
a = 0.2;
b = 0.2;
c = 5.7 ;
dx=zeros(3,1);
dx(1)=-x(2)-x(3); %here
dx(2)=x(1)+a*x(2); %and here
dx(3)=b+(x(3)*(x(1)-c));
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!