Plotting orbits of 3 ODE system

2 ビュー (過去 30 日間)
pj93
pj93 2015 年 2 月 17 日
回答済み: Mischa Kim 2015 年 2 月 20 日
Hi, I'm looking to plot orbits of the following ODE system
function dx=travformula(x,t)
global a b c I gam
dx(1)=x(3);
dx(2)=(1/(c*gam))*(x(1)-a+b*x(2));
dx(3)=-gam*x(3)-c*(x(2)+x(1)-(x(1)^3)/3+I);
dx=dx'; end
Where a b c I are all given, and gam (wavespeed) will be varied on different plots.
How can I go about plotting a 3D plot of the orbit?

回答 (1 件)

Mischa Kim
Mischa Kim 2015 年 2 月 20 日
pj93, use something like
function myorbit()
x0 = [1 1 1];
tSpan = [0 10];
a = 1;
b = 1;
c = 1;
I = 1;
gam = 1;
[~,X] = ode45(@travformula,tSpan,x0,[],a,b,c,I,gam);
plot3(X(:,1),X(:,2),X(:,3))
end
function dx = travformula(~,x,a,b,c,I,gam)
dx(1) = x(3);
dx(2) = (1/(c*gam))*(x(1)-a+b*x(2));
dx(3) = -gam*x(3)-c*(x(2)+x(1)-(x(1)^3)/3+I);
dx=dx';
end
Put both functions in one file and name it myorbit.m.

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by