\documentclass[12pt]{article}

\setlength{\textwidth}{6in}
\setlength{\oddsidemargin}{.30in}
\setlength{\textheight}{9in}
\setlength{\topmargin}{-0.5in}


\begin{document}

\noindent
Math 325

\noindent
Spring, 2001

\bigskip

\begin{center}
USING MATLAB TO PLOT TRAJECTORIES
\end{center}

\bigskip
There is a MATLAB program to do plots of trajectories 
of an autonomous
 system of 2 ODE.  (Autonomous means that the
equations are of the form  $x'=F(x,y), \ y'=G(x,y)\/$, so  
the independent variable $t\/$
doesn't appear explicitly in the equation.)

To use it under X windows or Open Windows on a 
Sparc station in one of the clusters, at the prompt give
the command: {\bf matlab}.  Once MATLAB has started and you have
the MATLAB prompt $>>$, give the command {\bf pplane5} (in MATLAB).
(The name pplane5 stands for phase plane, version 5.)
This program is very easy to use and self explanatory.  
However, in case you want it, here's some documentation.

A {\bf PPLANE5 Setup} window will 
pop up.  In the {\bf differential equations} box
it has a sample system.  In the {\bf display window} box
 it has sample range for
the dependent variables.
Replace the sample system  and range with the ones you want.  If there
are parameters in the equations, give their values in 
the {\bf parameters} box.
(The first time you use pplane, you might want to try the sample.)
In the {\bf direction field} window you can choose whether you want
arrows (the default), line segments or neither, and also how many 
arrows or line segments you want per row and
 column.  
Click on the {\bf Gallery} button in the upper left corner to get
a list of systems  
{\bf pplane5} knows.  
The {\bf linear system} is particularly useful; it gives you
a general constant coefficient linear system, with 
the coefficients as parameters.  You enter the values you want for 
the coefficients in the {\bf parameters} box.

Then click on the {\bf proceed} button.
A {\bf PPLANE5 Display}  window will pop up, and, assuming you 
did not change the arrows setting in the PPLANE5 Setup box,
 the direction field  
will be drawn.  (At a point  $(x_0,y_0)\/$ 
the direction field will point in the direction
$(F(x_0,y_0),G(x_0,y_0))\/$.  It is tangent to the trajectory 
through  $(x_0,y_0)\/$.)

To get a plot of the trajectory through a given point, 
 click at the point.
Some information about the trajectory might appear
in the main matlab window (the window where you entered 
the command {\bf matlab}).

Under {\bf Solutions} there is a menu which includes various options.
Here is a description of some of them.
An equilibrium point is a point 
which is a trajectory.  To find equilibrium points, use 
{\bf Find an equilibrium}, then click near where there is an equilibrium point.
A little circle will appear at the point on the plot and 
a {\bf PPLANE5 equilibrium point data}
 window will appear with information about the point.  It also allows
 you to display the linearization.
To find trajectories
which tend to a saddle point as  $t\to \infty\/$
or as  $t\to -\infty\/$,  use  the {\bf Plot stable and unstable orbits} 
option, then click on 
the saddle point.  
The {\bf Keyboard input} option can
be used to enter the coordinates of a point for the start
of a trajectory, rather than using the mouse to choose the 
start.  
The {\bf List computed equilibrium points} option gives a list
of the equilibrium points and their types in the main matlab 
window.  

One option under the {\bf Tools} menu is the {\bf Add} menu, which has
a text option that you can use to type text on the plot. 
However, I have found that then causes problems if I try to 
insert the plot into {\bf multigraf} (see below).  So, I suggest
adding text in {\bf multigraf} if you're using it, rather than in {\bf
pplane}.

Under  {\bf Graph} there are  options for plotting components of
trajectories, so, for example, {\bf  $x\/$ vs  $t\/$} plots  $(t,x(t))\/$.
There is also a {\bf 3D} option, for plotting  $(t,x(t),y(t))\/$.    

Use the {\bf Print}
button to send a copy of your plot to the printer.  If you want to
save it to a file, click on {\bf Print} in the {\bf File} menu,
then on {\bf File} under {\bf Send to:}, then on {\bf Save}.  A
dialogue box will pop up and ask for a file name.

If you want to print several plots on one sheet of paper, give the
command {\bf multigraf} at the matlab prompt.  This will get you a
window into which you can insert several (up to six) plots produced by
pplane5. You can also add text to the plots in this window.  Be sure to
click on {\bf Finish} before you print the graphs.


Use the {\bf Quit} button to quit the plot or
 the {\bf PPLANE5 Setup} window to quit pplane.

Give the command {\bf quit} at the matlab prompt to quit matlab.

You can enter any standard MATLAB command in the main matlab window.
Here are a couple of commands you might find useful.
To keep a transcript of a  matlab session (or part of one), 
enter the command {\bf diary} {\it filename}.  The command
{\bf diary off} suspends the diary and writes the session in 
{\it filename}.  Until you give the {\bf diary off} command,
the session is not written in the file.  
The diary command is useful, for example, if you want a record of the 
equilibrium points.
To put a title on the plot, enter the command
{\bf title} {\it 'your title'}.  


The OIT document {\it Using MATLAB 5.2}
is a good introductions to MATLAB and includes
additional information on these commands.  There are MATLAB manuals in the
clusters.


\end{document}
