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

 

 

 

Chaos - Duffing Oscillator

 

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

    delta = 0.06;

    beta = 1.0;

    w0 = 1.0;

    w = 1.0;

    gamma = 6.0;

    phi = 0;

     

    dy_dt = @(t,y) [y(2);...

                    -delta*y(2)-(beta*y(1)^3 + w0^2*y(1))+gamma*cos(w*t+phi)];

     

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

    [t,y] = ode45(dy_dt,[0 100], [3.0 4.1],odeopt);

    subplot(1,3,[1 2]);plot(t,y(:,1),'r-',t,y(:,2),'g-'); xlabel('time'); legend('y(1)','y(2)');

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