A Beginning MATLAB Tutorial for 

the UC Davis Department of Mathematics

by Sarah Williams

updated 9/15/2003


Introduction and Overview

Command-Line MATLAB

M-File MATLAB


Introduction and Overview

Please note that MatLAB can be accessed both on the department computers and from home via SSH. From home, one can even combine SSH with X Windows to use the graphical version of MatLAB.

What is MATLAB?

MATLAB is both a programming language and a software package.  "MATLAB" stands for "Matrix Laboratory."  Accordingly, many features exploit matrices, and assume you are working with matrices.  MATLAB generally solves problems numerically, not symbolically (compared to Mathematica).

Why use MATLAB? Why not?

Pros:

Cons:


Command-Line MATLAB

Launch MATLAB

Generate matrices

Implement functions

Write a small program that generates a plot



M-File MATLAB
Typing commands directly to MATLAB is well and good, and you will want to experiment at the command line frequently.  However, for homework assignments and other distinct problems, you will want to keep your program in a file, so that you can edit it and run it again.  You will also want to make files that call each other -- for example, you could have a plotting routine that uses the format you like, and each of your programs could call this routine when it comes time to make a graph.

Directory Structure (where will you save your file?)

Now is the time when we talk about Linux.  If you already know which directory you will save your program files in, skip to the next section.

Put your small program into an m-file, and run it

Scripts vs. Functions: write a function m-file


Get your scripts and functions talking

Add More Features and Get More Help