function phaseline
 
   % [t,u] = ode45(@f,[t0,tf],u0)
   % ode45 = runga-kutta 45. One of matlab's many solvers.
   % INPUT
   %  dudt = f is the differential equation to solve.
   %  [t0, tf] = the interval of time to solve the ode.
   %  u0 = the initial value of u.
   % OUTPUT:
   %  t = array of time values for which solution was computed.
   %  u = array of u values, the solution.
   [t,u] = ode45(@f,[0 10],0.9); %    

   figure(1) % Solutions as a function of time.
   subplot(2,1,1) % 2x1 array of plots, 1st plot.
      uvalues = -2:0.01:2; % Create an array of uvalues.  
      usize = numel(uvalues); % Number of elements in array. How many u values are there.
      for i=1:usize % For each u value, compute the dudt = f value.
        fvalues(i) = f(0,uvalues(i)) ; %f requires a value for time. Just set to any #. It's not used.
      end
      plot(uvalues,fvalues);
      hold on % Don't finish plot. Hold to add more functions to the plot.
      plot([-2,2],[0,0],'r'); % plot a red reference line at f = 0.
      hold off
      xlabel('u')
      ylabel('du/dt = f(u)')
      % axis([0 2 -2 2]); % Set plot axis to [tmin tmax xmin xmax]. Useful for "Single Species Pop."

   subplot(2,1,2) % 2x1 array of plots, 2nd plot.
      plot(t,u);
      xlabel('t')
      ylabel('u')
      % axis([0 10 0 3]); % Set plot axis to [tmin tmax xmin xmax]. Useful for "Single Species Pop."
 	
end

function dudt = f(t,u)

   global parameters
   dudt = zeros(1,1); % Create a column vector.
	
    dudt(1) = u(1)^2 - 1.0; % Example 1
   % dudt(1)= u(1) - u(1)^3; % Example 2
   % dudt(1)= exp(u) - 1.0;  % Example 3
   % dudt(1)= sin(u) - 0.5;  % Example 4.

   % Example from homework on "Single Species Populations."
   % beta = 1.0;
   % D = 1.0;
   % dudt(1) = beta*u(1)*(D - u(1)) - u(1)/(1.0+u(1));
  
end
