There are great utilities in Matlab called inline functions. These are like macros in C.
you can define a functions of two or three variables or a single variable in matlab.
this is the syntax…
f = inline(‘expression’,’arg1,’arg2′)
and you call the function as
f(x,y)
now if you need to define x+y in matlab you need to write as
f = inline(‘x+y’,’x’,’y’);
by the way single quotes are necessary.
you call the function as
f(x,y);
f(1,2) gives results 3..
just paste the following lines in matlab command windo and press enter for testing
f = inline(‘x+y’,’x’,’y’)
f(2,3)
Njoy