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 CenterFile Exchange 中查找有关 App Building 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by