Engineering Math - Quick Reference                                 Home : www.sharetechnote.com

 

 

 

Chaos - Lorenz Attractor

 

Description/Explanation will come later.

 

 

 

    %Save the following contents in a .m file and run the .m file

    % this is tested only in Matlab, not in Octave

    P = 10;

    r = 28;

    b = 8/3;

     

    dy_dt = @(t,y) [-P*y(1)+P*y(2);...

                        r.*y(1)-y(2)-y(1)*y(3);...

                        y(1)*y(2)-b.*y(3)];

     

    odeopt = odeset ('RelTol', 0.00001, 'AbsTol', 0.00001,'InitialStep',0.5,'MaxStep',0.5);

    [t,y] = ode45(dy_dt,[0 250], [1.0 1.0 1.0],odeopt);

     

    subplot(1,3,1);plot(y(:,1),y(:,2),'r-'); xlabel('y(1)'); ylabel('y(2)');

    subplot(1,3,2);plot(y(:,2),y(:,3),'g-'); xlabel('y(2)'); ylabel('y(3)');

    subplot(1,3,3);plot(y(:,1),y(:,3),'b-'); xlabel('y(1)'); ylabel('y(3)');