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.
- Matlab Basics: start up, simple commands, Matlab as calculator
- Matlab Variables: Vectors and Matrices
- Linear Equations
- Simple programming: control of flow, functions, m-files
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
In the command window, type:
There are other ways!
All matlab variables are arrays. To create an array:
Axis labels, etc.:
Example – Dot product, angle between vectors:
other Matrix operations: reshape, sort, etc.
Matrix example (Linear Equations):
Some 3D plotting
m-FILES (SCRIPTS AND FUNCTIONS)
Scripts: A collection of matlab commands in a file named <name>.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.
Additional tutorial material: fwdmatlabtutorialsetc.zip