Using ODE45 to solve Rossler equations

조회 수: 10 (최근 30일)
jacob Mitch
jacob Mitch 2019년 11월 8일
답변: Tanggo Tang 2021년 3월 29일
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개)

Jeremy
Jeremy 2019년 11월 8일
You are correct ode45 appears to be stuck. But if you try
ode15s
it appears to work
  댓글 수: 1
Jeremy
Jeremy 2019년 11월 8일
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
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

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by