Using the C++ Math Library    

Functions

In addition to the operators defined by the language, MATLAB ships with a large collection of functions. While there is no way for you to add a new operator to the language, you may add as many functions as you want to MATLAB.

A MATLAB function can take zero, one, or more input arguments, and return zero, one, or more output arguments. In general, a MATLAB function call looks like this:

This calls the function foo() with three input arguments, a, b, and c, and assigns the two results to the output arguments x and y.

You can also compose functions:

Note that there is no way to pass multiple return values from one function to the next. In this example, only the first of foo()'s return values is passed to bar().

Finally, one or more of a MATLAB function's input or output arguments may be optional. A MATLAB function can never be called with more input or output arguments than it is declared with, but it can always be called with fewer. It is up to the function implementer to put in any necessary error checking.

See How to Call C++ Library Functions in Chapter 5 for a complete description of the rules that govern function calls in MATLAB.


 Operators Input and Output