% L63 integrates the Lorenz equations. % % This is a self-contained program that integrates the Lorenz % equations and plots the resulting attractor. The code is not % interactive, but the initial conditions, parameters, and % integration time scales are easily changed by hand. % The Lorenz equations are: % x_dot = -sigma*x + sigma*y % y_dot = -x*z + r*x - y % z_dot = x*y - b*z % % The parameters sigma, r, and b are set at their default % values of 10, 28, and 8/3, respectively. % Written by Jim Hansen, August 2002 for use by 12.800 students. % Specify the dimension of the system dim = 3; % Specify the initial conditions x = [10 20 30]; % Specify the parameter values (sigma, r, and b) par = [10 28 8/3]; % 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('lorenzeq',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('lorenzeq',x,par,h,dim); state(i,:)=xout; x=xout; end % Make a pretty picture figure;plot(state(:,1),state(:,2),'.'); title('The Lorenz attractor'); xlabel('x');ylabel('y'); % Save picture to disk print -depsc lorenz.ps sprintf('%s','The plot is saved as lorenz.ps')