%EXAMPLE of a function m-file to compute the solution of a first-order system
%This is a function m-file to compute the solution of
%            x''=4x(1-x^2)
%   t in [0,10]       x(0)=0      x'(0)=1
%written as a system  for the vector [x(t,1), x(t,2)], where x(t,1)=x(t), x(t,2)=x'(t)]
function xprime=example5(t,x)
xprime=zeros(2,1);
xprime(1)=x(2);
xprime(2)=4*x(1)*(1-x(1)^2);
%Once this is saved as example5.m, the call to the ode solver would be:
%[t,x]=ode45(@example5, [0,10], [0;1])
%(the second argument is the time interval, the last argument is the column vector with the initial conditions)
%Then to plot both components (remember to quit pplane7 if it is open):
%     plot(t,x)
%and to plot just the first component, that is, x(t):
%  plot (t,x(:,1))