% Plot outcomes of Van der Pol oscillator for µ varying bewteen -1.8 and 2.4.
% 
% The van der Pol equation (y_1)"-µ*(1-(x_1)^2)*y'+(y_1)=0 is equivalent 
%    to a system of coupled first-order differential equations
%       (y_1)'=(y_2)
%       (y_2)'=µ*[1-(y_1)^2]*(y_2)-(y_1).
%
%    for -1.8 =< µ <= 2.4.
%
% see also "vdpeqMU.m"


% Initial values: x0=[1 0];
global mu
for OM=2.3:0.01:6.4;
    mu=(OM-4);
    if mu<0;    
x0=[1 0];
    pause(0.000001)       
    [t,Q] = ode45(@vdpeqMU,[0 1400],x0);
 plot3(t,Q(:,1),Q(:,2),'b');
xlabel('time t');
ylabel('solution y_1');
zlabel('solution y_2');
title(['Van der Pol oscillator with \mu= ', num2str(mu)]);
axis([1 1400 -1 1 -1 1]); grid;

% For representation convenience, initial values are switched here 
% to be equal to x1=[0.0001 0.0001];
   else mu>=0;
   
 x1=[0.0001 0.0001];
    pause(0.001)
         
     [t2,E] = ode45(@vdpeqMU,[0 400],x1);
plot3(t2,E(:,1),E(:,2),'b');grid;
title(['Van der Pol oscillator with \mu= ', num2str(mu)]);
axis([0 400 -4 4 -4 4]);

    end    

end



% "Complex and Chaotic Nonlinear Dynamics. 
% Advances in Economics and Finance, 
% Mathematics and Statistics" 
% T.Vialar, Springer 2009
% Copyright(c).