## A short introduction to Matlab

The purpose of this web page is to introduce Matlab to students of mathematics. It is not exhaustive, but describes commands and subroutines that might be commonly used by mathematicians.

This tutorial is intended as a cut and paste tutorial to Matlab's capabilities. The reader would be served to have this web page open along with a Matlab window. To execute Matlab in a Unix environment, at the prompt, type

`matlab`
and return. If Matlab is successfully executed, a small pop up window will appear with the Matlab logo. In the Unix window, an introductory message will stream by and the matlab prompt
`>> `
will appear. To enter commands in Matlab, simply type them in. Beware that Matlab is case sensitive.

This tutorial contains Matlab code. Each line of Matlab code starts with the prompt >>. When you cut a segment of code from this tutorial, do not cut the prompt >> .

Matlab is an interpreted language for numerical computation. It allows one to perform numerical calculations, and visualize the results without the need for complicated and time consuming programming. Matlab allows its users to accurately solve problems, produce graphics easily and produce code effeciently.

Because Matlab is an interpreted language, it can be slow, and poor programming practices can make it unacceptably slow.

# Some features of Matlab

### 1. Matlab help facilities

1.1 Inline help
1.2 Web based support and help
1.3 Who, whos and clear
1.4 Recording your Matlab session

### 2. Matlab matrices and vectors

2.1 Dense matrices and vectors
2.2 Sparse matrices and vectors
2.3 Range operators
2.4 Grid operators
2.5 Size and shape operators
2.6 Special matrices

### 3. Matlab arithmetic operators

3.1 Matrix-vector operations
3.2 Array operations
3.3 Backslash operator
3.4 Complex arithmetic

### 4. Matlab software

4.0 Elementary functions
4.1 Linear algebra
4.2 Nonlinear functions
4.3 Ordinary differential equations
4.4 Fourier transformations

### 5. Matlab graphics

5.1 Plotting (x,y) data
5.2 Axis control
5.3 Plotting (x,y,z) data
5.4 Saving postscript graphs
5.5 Movies

### 6. Matlab data handling

6.1 Importing ascii data
6.2 Exporting ascii data

### 7. Programming hints

7.1 Some basics
7.2 m-files
7.3 Good practices

### 8. Examples of problems solved with Matlab

8.1 Matrix examples
8.1.1 Largest eigenvalue of a random dispersion matrix
8.1.2
8.2 Partial differential equations
8.2.1 Solve a semi-linear heat equation
8.2.2 Solve the Cahn-Hilliard equation

### 9. Some more advanced examples.

9.1 Using C++ with Matlab

David Eyre
9/8/1998