Using ODE45 to solve Rossler equations

11 ビュー (過去 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
  1 件のコメント
darova
darova 2019 年 11 月 8 日
Try
tspan = [0 2];

サインインしてコメントする。

回答 (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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by