% This program plots phase portraits for the 2nd-order van der Pol ODE.
% u'' - mu (1-u^2)u' + u = 0.
% Since this is a 2nd-order ODE, we plot the phase portrait
% [u, u'].
% This program calls for a step size, number of steps, and a parameter mu.

step=input('Enter the step size: ');
n=input('Enter the number of steps: ');
x=input('Enter the starting values [u, u-prime]: ');
mu=input('Enter the parameter mu: ');
c=input('Enter a color and marker in quotes: ');

A=zeros(2,n+1);
A(:,1) = x';

for i=1:n
A(:,i+1) = A(:,i) + step.* [A(2,i); -A(1,i) + mu.*(1-A(1,i).^2).*A(2,i)];
end

plot(A(1,:),A(2,:),c)
hold on;
