% Main program: Save the program in a separate .m file and run it.
function vanderpol
t=linspace(0,30,10000)'; % time variables
y0=[0.1;0]; % Initial conditions
[t,Y] = ode45(@myVan,t,y0); %Invoking built-in solver 'ode45'

figure(1);
plot(Y(:,1),Y(:,2),'g-','LineWidth',2);  % Plot results
grid on;

figure(2);
plot(t,Y(:,1),'b-',t,Y(:,2),'r-.','LineWidth',2);


figure(3);
plot(t,Y(:,1),'b-','LineWidth',2);

function dxdt=myVan(t,x)

k = 10;

dxdt=[x(2);
-x(1)-k*(x(1)*x(1)-1)*x(2)];
end
end