MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
Use only in the MuPAD Notebook Interface. This functionality does not run in MATLAB.
The functions of the fp
package are higher
order functions and other utilities useful for functional programming.
Some other functions useful for functional programming are already
contained in the MuPAD® standard library, like map
, select
and zip
.
For a more detailed description of concepts like “higher order function”, “currying” and “fixed points” see for example the textbook “Computability, Complexity and Languages” by M. Davis, R. Sigal, and E. J. Weyuker, Academic Press (1994).
Most of the functions of the fp
package take
functions as arguments and return other functions. In this context
a function may be a functional environment, a procedure, a kernel
function or any other object which may be regarded as a function (i.e.
applied to arguments). Note that almost all MuPAD objects are
functions in this sense.
The rational integer 2/3
for example may
be regarded as a constant function returning the value 2/3
:
2/3(x)
The list [sin, cos, 2/3]
may be regarded
as a unary function mapping x
to [sin(x),
cos(x), 2/3]
:
[sin, cos, 2/3](x)
The library functions are called in the form fp::fixedpt(f)
.
By this mechanism, naming conflicts with other library functions are
avoided. If this is found to be too awkward the methods of the fp
package
may be exported. After calling use(fp, fixedpt)
the
function fixedpt
is also directly available, i.e. fixedpt(f)
may
also be called. If a variable with the name fixedpt
already
exists then use
raises
an error. The value of the identifier fixedpt
must
then be deleted in order to be exported. With use(fp)
all
methods of the fp
package are exported.