Using the C++ Math Library | ![]() ![]() |
Passing Optional Input Arguments
Some MATLAB functions take optional input and output arguments. tril()
, for example, which returns the lower triangular part of a matrix, takes either one or two input arguments. If present, the second input argument, k
, indicates which diagonal to use as the upper bound; k=0
indicates the main diagonal and is the default if no k
is specified. In interpreted MATLAB you invoke tril()
either as
L = tril(X)
L = tril(X, k)
where L
, X,
and k
are matrices. k
is a 1-by-1 array.
The MATLAB C++ Math Library contains two versions of the tril()
function. The first version takes one argument; the second takes two arguments. The two ways to call the MATLAB C++ Math Library versions of tril()
are exactly the same as the two ways you can call tril()
in interpreted MATLAB
L = tril(X);
L = tril(X, k);
where L
, X
and k
are mwArray
objects.
![]() | Returning One Result and Passing Only Required Input Arguments | Passing Optional Output Arguments | ![]() |