Originally Posted by

**Maccaman** So if my 2nd order ode is

$\displaystyle x'' = \mu (1-x^2)x' -x $

then how is that in MATLAB?

Is it something like

function z = xdot (t,x);

mu = 0.1;

z(1) = x(2);

z(2) = x(3);

z(3) = mu*(1-z(1)^2)*z(2) - z(1); A second order ODE converts to a first order ODE with a 2-D state, so no.

$\displaystyle X={x \brack x'}$

so for your ODE:

$\displaystyle

X'={x' \brack x''}={X_2 \brack \mu(1-X_1^2)X_2 - X_1}

$

So:

Code:

function z = xdot (t,x);
mu = 0.1;
z(1) = x(2);
z(2) = mu*(1-x(1)^2)*x(2) - x(1);

RonL