M files

An external Matlab/Octave file is called an M files. First you have to save the M file of your interest in order to use it. Then run Matlab/Octave and at the screen with prompt ``>'' type

> cd [the directory where M files are saved]
If you are using Octave, save M files under ``C:\Program Files\GNU Octave\'', simply type
> cd
or ``cd /''; then check if the current place is ``/'' by typing ``pwd''. To make sure whether the M file is under this directory, we can use
> ls
If you see it, say ``yourfunction.m'' in the screen, you are ready to execute the function ``yourfunction()''.

Here are a few M files we might want to use throughout this material:

idemo.m idemo('[script file]') executes a Matlab/Octave script line by line. In Matlab, you can call it by
> idemo(uigetfile('*.m','Load M file'))
In Octave you have to set
default_eval_print_flag = 1
to display the output properly.
rref.m R = rref (A, tol) returns the reduced row echelon form of A.
arrow.m arrow([x0,y0],[x1,y1]) drows an arrow from $ (x_0,y_0)$ to $ (x_1,y_1)$ in xy-coordinate.
pmatrix.m pmatrix(n) generates an n-by-n probability transition matrix consisting of random entries.

You can find many more M files and custom scripts, and extensions for GNU Octave at GNU Octave Repository.



Department of Mathematics
Last modified: 2005-10-21