Plotting orbits of 3 ODE system

2 visualizaciones (últimos 30 días)
pj93
pj93 el 17 de Feb. de 2015
Respondida: Mischa Kim el 20 de Feb. de 2015
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?

Respuestas (1)

Mischa Kim
Mischa Kim el 20 de Feb. de 2015
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.

Categorías

Más información sobre App Building en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by