Using the C Math Library | ![]() ![]() |
Summary of Library Calling Conventions
Though this section has focused on just a few functions, the principles presented apply to the majority of the functions in the MATLAB C Math Library. In general, a MATLAB C Math Library function call consists of a function name, a set of input arguments, and a set of output arguments. In addition to being classified as input or output, each argument is either required or optional.
The type of an argument determines where it appears in the function argument list. All output arguments appear before any input argument. Within that division, all required arguments appear before any optional arguments. The order, therefore, is: required outputs, optional outputs, varargout
or mlfVarargoutList
output (a varargout
output list), required inputs, optional inputs, and variable-length inputs (varargin
arguments).
To map a MATLAB function call to a MATLAB C Math Library function call, follow these steps:
mlf
.
Find the MATLAB call with the largest number of arguments. Determine which input and output arguments are required and which are optional.
mlfVarargout()
or mlfIndexVarargout()
in the last output argument position.
NULL
argument wherever an optional output argument does not apply to the particular call you're making.
NULL
argument wherever an optional input argument does not apply to the particular call.
Passing the wrong number of arguments to a function causes compiler errors. Passing NULL
in the place of a required argument causes runtime errors.
Note The online MATLAB C Math Library Reference does the mapping between MATLAB and C functions for you. Access the Reference from the Help Desk. |
Exceptions to the Calling Conventions
The mlfLoad()
, mlfSave()
and mlfFeval()
functions do not follow the standard calling conventions for the library. For information about mlfLoad()
and mlfSave()
, see Chapter 7, Importing and Exporting Array Data.. For information about mlfFeval()
, see Passing Functions As Arguments to Library Routines.
![]() | Variable Output Arguments | Example - Calling Library Routines (ex3.c) | ![]() |