# Overview

This is a simple tutorial to get you started with Matlab. Matlab makes it easy to perform scientific computations without having to learn a programming language such as Fortran, C, or C++. This tutorial is developed keeping assignment_0.pdf for AM205 in mind. It can be used for other classes as well.

Topics covered:

- Matlab Basics: start up, simple commands, Matlab as calculator
- Matlab Variables: Vectors and Matrices
- Linear Equations
- Simple programming: control of flow, functions, m-files
- Plotting

## References

You should make use of online search tools such as google to search for relevant matlab material. There is a lot of material on the web.In addition

- Comprehensive online documentation at the Matlab site: http://www.mathworks.com/help/techdoc/index.html
- Another site: http://en.wikibooks.org/wiki/MATLAB_Programming
- Numerical Computing with MATLAB by Cleve Moler
- A Non-matlab, but very useful book: Numerical Recipes (2007). William H. Press, Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery. Cambridge University Press

## Getting Help

In the command window, type:

There are other ways!

## ARRAYS

All matlab variables are arrays. To create an array:

Axis labels, etc.:

From: http://www.mathworks.com/help/techdoc/ref/plot.html

## VECTORS:

Example – Dot product, angle between vectors:

(compare)

use:

format long

## MATRICES

other Matrix operations: reshape, sort, etc.

## Matrix example (Linear Equations):

Equation:

2x1+4x2+3x3=4

x1-2x2-2x3=0

-3x1+3x2+2x3=-7

Ax=B

## Some 3D plotting

Sinc Function:

Another example:

## m-FILES (SCRIPTS AND FUNCTIONS)

Scripts: A collection of matlab commands in a file named <name>.m.

Example: example.m

Functions: Matlab functions are callable sub-procedures that are

put in a file named <function_name>.m

Example function (stat.m) is as follows:

The following are some functions relevant to assignment_0.pdf of AM205.

They are meant to get you started with the problems, but they are not "complete solutions".They can be useful for learning functions in matlab for other classes as well.

Function (cheby.m):

Function: sinTaylorSeries.m

Function: tanderiv.m

Additional tutorial material: fwdmatlabtutorialsetc.zip