Contents Previous Next Subchapters

User Defined Functions (Mlmode)

Functions defined in Mlmode correspond to a file with the same root name as the function and the *.m file extension. If the file begins with the word function it is interpreted as a function. Otherwise it is interpreted as a script .

The syntax for defining a function in Mlmode is similar to the multiple return syntax in O-Matrix mode with the exception that the local option is not available and if there is only one return variable, it need not be enclosed in brackets. To be specific, the possible forms for a function definition are
variable = name ( arguments ) statement list EOF
     function [ 
variables ] = name ( arguments ) statement list EOF
where the function keyword is a the beginning of the file and EOF denotes the end of the file.

Suppose that the file temp.m in the current working directory contains the text
     function y = temp(x)
     y = 2 * x;
and you enter
O-Matrix will respond

O-Matrix Mode
User-Defined Functions