% Integrate the Moore-Spiegal equations.

% Moore, D.W. and E. A. Spiegel, 1966, A thermally excited nonlinear
% oscillator, Journal of Astrophysics, 143, 3, 871-887.

% System equations:
% \dot{x}(1) =  x(2)
% \dot{x}(2) =  x(3)
% \dot{x}(3) = -x(3)-(a-b+b*x(1)*x(1))*x(2)-a*x(1);

% Written by Jim Hansen, Feb 2003 for 12.990 students

% Specify the dimension of the system
dim = 3;

% Specify the initial conditions
x = [1 2 3];

% Specify the parameter values (a, b)
par = [26. 100.];

% Specify the integration step size
h = 0.01;

% Specify the length of integration
steps = 2^12;

% Integrate the equations over length steps to remove any transient behavior
for i=1:steps
 xout=step_it('derivsms',x,par,h,dim);
 x=xout;
end

% Integrate the equations over length steps and record state for plotting
for i=1:steps
 xout=step_it('derivsms',x,par,h,dim);
 state(i,:)=xout;
 x=xout;
end

% Make a pretty picture
figure;plot3(state(:,1),state(:,2),state(:,3)'.');
title('The Moore-Spiegal attractor');
xlabel('x');ylabel('y');zlabel('z');

print -djpeg90 ms.jpg
