Using ODE45 to solve Rossler equations
21 views (last 30 days)
Show older comments
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
Answers (2)
Jeremy
on 8 Nov 2019
You are correct ode45 appears to be stuck. But if you try
ode15s
it appears to work
1 Comment
Jeremy
on 8 Nov 2019
One more thing - are you plotting the equation solutions vs themselves instead of vs. time intentionally?
figure, hold on
plot(t,x(:,1),t,x(:,2),t,x(:,3),'LineWidth',2)
Tanggo Tang
on 29 Mar 2021
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 Comments
See Also
Categories
Find more on Ordinary Differential Equations 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!