
4 Programming
Function
s
Function
s are M-files that can accept input arguments and return output
argument
s. ThenamesoftheM-fileandofthefunctionshouldbethesame.
Function
s operate on variables within their own workspace, separate from the
workspa
ce you access at the M ATLAB command prompt.
A good ex
ample is provided by
rank.TheM-filerank.m is available in the
directo
ry
toolbox/matlab/matfun
You can see the file with
type rank
Here is the fil e:
function r = r ank(A,tol)
% RANK Matrix rank.
% RANK(A) provides an estimate of the number of l inearly
4-22
Commenti su questo manuale