Math 251H, Fall 2006

Matlab Introductory Tutorial

John Zweck

The Matlab software is a product of The MathWorks, and the best way to get familiar with it is to use The MathWorks excellent documentation.

In this tutorial you will read selected parts of Matlab's documentation, experiment using Matlab for yourself, and use Matlab to do some problems in Multivariable Calculus. In what follows I will be referring to the Getting Started web pages.

(1) First read the sections "What is MATLAB?", "MATLAB Documentation", and "Starting and Quitting MATLAB".

(2) Now start up Matlab for yourself. To learn what the different windows are for look at the documentation "MATLAB Desktop".

(3) In the Command Window type "intro" to learn how to enter vectors and matrices and plot data. (Don't expect to understand all the math just yet!)

(4) Try entering a vector such as v = [1 7 4 6] for yourself and then plot it.
Notice that Matlab joins up the individual data points (1,1), (2,7), (3,4), (4,6) with straight lines.

(5) Next read the section "Manipulating Matrices" as far as the page on "Examples of Expressions".

(6) A row vector is a 1 x n matrix and a column vector is an n x 1 matrix.
Enter a row vector v whose components are (1,2,3), and a column vector w whose components are (4,5).
Make sure that Matlab echoes back to you the row and column vectors you hoped it would!
To check the size of a matrix or vector use the size command, as in "size(v)".
To compute the length of a row or column vector u you enter "norm( u)".
Compute the lengths of the vectors v and w.



When you turn in homework that you did using Matlab you should do the following.
You can store a list of matlab commands in a script file with a name like homework1.m. That way if you have to rerun a series of commands several times without heaps of typing. There are several scripts on the course web page.
Read about the Matlab diary command using help diary. Turn on a diary file homework1.diary and then echo your script homework1.m to the screen using the command type homework1. Then run the script generating your results. Finally turn your diary off. To print your figures, choose the option print from the pulldown menu file at the top left of the figure. You can also use the save as option in file to generate a .eps or .pdf file which you can later print.

Everytime you hand in Matlab homework, you need to hand in the code used to generate the results, a print out of any text generated when you run the code, as well as neat, labelled figures!