Math 5-385 Fall 2007
Info about using the matlab scripts
Last updated September 18, 2007
{Scroll down to see the contents of this page.}
General intro: The scripts can be downloaded to each student's home directory from the "Downloadable copies" link below. They provide tools for visualizing implicitly defined plane curves, and families of such curves that are better than the most standard Matlab tools and easier to use than the more powerful Matlab tools.
The scripts were written by Rory Mulvaney as part of a Summer `00 REU project. His project report in PDF format is linked below. The report includes descriptions, with examples, of all of the scripts.
Contents
Accessing the scripts from your class account
(An important preliminary step is omitted here.)
We will deal with this in class (in the computer lab) on September 12, when I'll
show you how to download copies of the scripts to your home directory.
Remote access to your class account
Note: If you don't need to use the scripts and the software
(Matlab, Maple, Mathematica, or whatever) is installed at the remote
location, then you actually don't need to bother with this process ...
A couple of useful Matlab commands
Adding stuff to your drawing
Printing the graphics window
Obtaining a color print
The scripts
Comments and questions to: roberts@math.umn.edu
Back to
the help page index.
Back to the Math 5385 class homepage.
from either (a) our lab or (b) a remote location.
{This usually produces a
black and white print.}
A bit less than halfway down, you'll
find the category Other, and you'll find Matlab in this category
along with Maple and Mathematica. Just start the program from here.
pwd
You will get a response something like this:
/user011/xxxx0000
where xxxx0000 is your actual username.
What you want to type at the next matlab prompt is:
path(path,'/user011/xxxx0000/scripts')
Of course, you substitute your own username in place of
xxxx0000.
And if you called the "scripts" directory something else,
be sure to change that part too.
Oh yes, be sure to use single quotes.
In either case, proceed to edit your
startup.m
file. After the editing, it should include the following lines:
homedir = getenv('HOME');
matlabdir = [homedir '/scripts'];
path(path, matlabdir);
clear homedir matlabdir
After logging on, type the following:
ssh hostname.math.umn.edu
or
ssh -X hostname.math.umn.edu
Here, "hostname" should be the name of one of the machines in
Vincent 5 or Vincent 314.
(for instance, the name of a machine that you have used when we
held class there).
The first alternative merely gives command line access; the second
will enable your computer to open an X window, and thus actually
display the graphics window. You'll now be able to start matlab
{in either case you need to use Method 2 for starting Matlab
and use the scripts, according to the instructions given above.
When finished: (1) type exit to quit
Matlab, and then (2) type exit again
to log off from your class account, and finally (3) do whatever
else you need to do from your IT account.
This is supposed to be possible, but I don't understand the details
well enough to explain it reliably. Some kind of ssh client needs
to be installed on the Windows machine, as well as some kind of
Xwindows software for the graphics window. Presumably, this software
may be installed on some PC's in the IT labs; ask the lab consultant
if this seems to be of interest.
If you have a figure
in the graphics window (such as a curve that you've plotted) and would like
to add something to it, like another curve, some lines, or whatever, then
go to the Matlab command window and type hold on
This will remain in effect "until further notice",
i.e., you can add as many (or as few) additional plots as you'd
like.
Suppose something
didn't go right while "hold on" was in effect, and you'd like to start over.
Or maybe you've finished one set of plots and would like to move on to the
next set. In this case you just go back to the Matlab command window and type
hold off Your next figure will
appear in a clean graphics window.
Click on the printer icon at the top of the graphics window. In the
box that pops up, be sure that it says vinp314
for the printer name. Just click on "print".
As an alternativetype the following in the Matlab window:
print -dps2 -Pvinp314
The device option -dps2 refers to level 2 Postscript.
For further info about this method type the following at the Matlab
prompt >>
help print
This is very similar to the above, except that the printer name
should be vinp005
scp hostname.math.umn.edu:filename.ps host2:filename.ps
You'll likely be prompted for your password at the opposite location.
"host2" should be the complete hostname of the machine at the
remote location [including the name of the actual machine]. If it
doesn't work from one end, open a window in the other account, and try it
from that end. It's supposed to work in either direction, but I have
found that it sometimes works better in one direction than in the other.
For more information, type the following at the system prompt:
man scp
Of course, "printername" should be the name of a printer at the
remote location. (Or maybe there's a default printer, so that this part
is redundant.
[C h] = aPlot(f, [xmin xmax ymin ymax], gridPoints)
f is an expression in x and y, and the equation f=0 is plotted
gridPoints may be a scalar or vector specifying the fineness of the
grid in both directions
returns a contour matrix in C (see help contour) and a column vector of
handles to the lines plotted
for example, to plot y = x^2, try
[c handles] = aPlot('x^2 - y', [-2, 2 -.4, 5], 50);
set(handles, 'color', 'r') % changes color of lines to red
Plots the multiple tangent lines at the singularities of a
two-dimensional algebraic curve.
[handles singPts initialForms] = cone(f, [xmin xmax ymin ymax], gridPoints)
f is an expression in x and y, and the singular points are found for the
equation f=0, and the multiple tangent lines are plotted at these points
gridPoints may be a scalar or vector specifying the fineness of the
grid in both directions
handles - handles to the lines ploted
pts - array of the singular points accessed by pts(i).x, pts(i).y
initialForms - cell array of strings representing the unfactored initial
form at each singularity
for example:
syms x y z
f = (x+y+1)*(x+y-1)*(y-x-1)*(y-x+1)+(x^2-1)^4+(y^2-1)^4-1;
[h p initialForm] = cone(f, [-2 2 -2 2], 200);
% returns a char array representing the output from maple of factoring the
% 1st singular point's initial form - note it's over the rationals, not reals
char(maple('factors', char(initialForm(1))))
see also: fCone, maple, mhelp, syms
envelopeFunc = envelope(f, var)
f should be a function of x, y and some other variable, named in var
[C fHan cHan] = fCone(f, [xMin xMax yMin yMax], gridPoints)
f is an expression in x and y, and the equation f=0 is plotted
gridPoints may be a scalar or vector specifying the fineness of the
grid in both directions
returns a contour matrix in C (see help contour), column vector of
handles to the lines of the function, and a column vector of handles to
the tangent lines
for example:
syms x y z
f = (x+y+1)*(x+y-1)*(y-x-1)*(y-x+1)+(x^2-1)^4+(y^2-1)^4-1;
[c fh ch] = fCone(f, [-2 2 -2 2], 200);
set(ch, 'linewidth', 3); % thickens line width of tangent lines
[env hFam hEnv]=famEnv(f,[zMin, zMax], steps, [xMin, xMax, yMin, yMax], gridPoints)
f is always to be a string expression containing only variables x, y, & z
z is always to be the parameter that is variable in the family
steps is a scalar specifying the number of frames in the movie
gridSteps is a scalar or 1x2 vector specifying the number of grid coordinates
in the x & y directions (higher for a more precise plot)
env - the equation of the envelope
hFam, hEnv - 2 column vectors of handles to lines in the plot, so the
color of the lines can be changed.
For example:
[fam hf he] = famEnv('(x-z)^2+(y-z^2)^2 - 4', [-4 4], 25, [-6 6 -2 6], 100);
set(hf, 'color', 'r') % changes color of family to red
set(he, 'linewidth', 2) % changes width of envelope to 2
set(hf(13), 'color', 'm') % changes color of the 13th curve to
magenta
set(hf(13), 'linewidth', 2) % thickens the 13th curve
handles = family(f,[zMin, zMax], steps, [xMin, xMax, yMin, yMax], gridPoints)
f is always to be a string expression containing only variables x, y, & z
z is always to be the parameter that is variable in the family
zRange is a 1x2 row vector
steps is a scalar specifying the number of frames in the movie
gridSteps is a scalar or 1x2 vector specifying the number of grid coordinates
in the x & y directions (higher for a more precise plot)
returns a column array of handles to lines in the plot, so the color of the
lines can be changed. For example:
h = family('(x-z)^2+(y-z^2)^2 - 4', [-4 4], 25, [-6 6 -2 6], 100);
set(h, 'color', 'r') % changes color of all curves to red
set(h(13), 'color', 'g') % changes color of the 13th curve to green
M=makeMovie(f, [xMin zMax], frames, [xMin xMax yMin yMax], gridPoints)
f is always to be a string expression containing only variables x, y, & z
z is always to be the parameter that is variable in the movie
zRange is a 1x2 row vector
frames is a scalar specifying the number of frames in the movie
gridSteps is a scalar or 1x2 vector specifying the number of grid coordinates
in the x & y directions (higher for a more precise plot)
example:
syms x y z
f = y^2 - x^3 + x + z;
m = makeMovie(f, [-2 2], 10, [-2 2 -2 2], 100);
see also: writeMovie, readMovie, playMovie, movie
MOVIE Play recorded movie frames.
MOVIE(M) plays the movie in array M once. M must be an array
of movie frames (usually from GETFRAME).
MOVIE(M,N) plays the movie N times. If N is negative, each
"play" is once forward and once backward. If N is a vector,
the first element is the number of times to play the movie and
the remaining elements comprise a list of frames to play
in the movie. For example, if M has four frames then
N = [10 4 4 2 1] plays the movie ten times, and the movie
consists of frame 4 followed by frame 4 again, followed by
frame 2 and finally frame 1.
MOVIE(M,N,FPS) plays the movie at FPS frames per second. The
default if FPS is omitted is 12 frames per second. Machines
that can't achieve the specified FPS play as fast as they can.
MOVIE(H,...) plays the movie in object H, where H is a handle
to a figure, or an axis.
MOVIE(H,M,N,FPS,LOC) specifies the location to play the movie
at, relative to the lower-left corner of object H and in
pixels, regardless of the value of the object's Units property.
LOC = [X Y unused unused]. LOC is a 4-element position
vector, of which only the X and Y coordinates are used (the
movie plays back using the width and height in which it was
recorded). All four elements are required, however.
See also GETFRAME, MOVIEIN, IM2FRAME, FRAME2IM.
M=playMovie(name)
plays the movie that was saved to disk using writeMovie, and also
restores the title and axis ranges, which aren't stored in a movie matrix
example:
syms x y z
f = y^2 - x^3 + x + z;
m = makeMovie(f, [-2 2], 10, [-2 2 -2 2], 100);
saveMovie(m, 'myMovie');
mov=playMovie('myMovie');
see also: writeMovie, movie, makeMovie, readMovie
[M str]=readMovie(movieName)
Returns the movie matrix in M, and a character string that can be evaluated
using eval(str) in order to set the title and range of the movie in the
plot window (this isn't recorded in the movie matrix M)
example:
syms x y z
f = y^2 - x^3 + x + z;
m = makeMovie(f, [-2 2], 10, [-2 2 -2 2], 100);
saveMovie(m, 'myMovie');
[mov str] = readMovie('myMovie');
eval(str); % sets the title and x and y range of the movie
movie(mov); % plays the movie that was read from files
see also playMovie, makeMovie
func = replace([in1 in2 in3...], [out1 out2 out3...])
in's and out's must be syms
in1 is substituted with out1, in2 is substituted with out2...
example:
syms x y z
f = (x-z)^2+(y-z^2)^2 - 4
g = replace(f, [y z], [z y]); % in g, y & z are swapped
writeMovie(movieMatrix, name)
Writes a series of tiff files to a subdirectory named by the parameter
'name', as well as additional info to recover the title and xyRange of the
movie
example:
syms x y z
f = y^2 - x^3 + x + z;
m = makeMovie(f, [-2 2], 10, [-2 2 -2 2], 100);
writeMovie(m, 'movieName');
see also: readMovie, playMovie, makeMovie, movie