Plotting orbits of 3 ODE system

2 vues (au cours des 30 derniers jours)
pj93
pj93 le 17 Fév 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?

Réponses (1)

Mischa Kim
Mischa Kim le 20 Fév 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.

Catégories

En savoir plus sur App Building dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by