matlab::mex::ArgumentList
Container for inputs and outputs from C++ MEX functions
Description
C++ MEX functions pass inputs and outputs as matlab::data::Array
objects contained in matlab::mex::ArgumentList objects. The
MexFunction::operator() accepts two arguments, one for inputs and
one for outputs, defined as matlab::mex::ArgumentList.
ArgumentList is a wrapper enabling iteration over the underlying collections holding the input
and output data.
Class Details
|
Namespace: | matlab::mex |
|
Include: | mex.hpp |
Member Functions
operator[ ]
matlab::data::Array operator[](size_t idx)Enables [] indexing into the elements of an
ArgumentList.
| Index into the elements of the input array, which are the input arguments to the MEX function |
| Iterator pointing to the first element in the
|
Call a MEX function from MATLAB® with an array, a scalar, and a character vector as inputs and a single output:
a = myMEXFunction(array, scalar, 'character vector')Assign the first input argument to a TypedArray, the second input to a
scalar const
double (assume both are of type double in
MATLAB), and the third input as a matlab::data::CharArray.
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
matlab::data::TypedArray<double> inArray = inputs[0];
const double inScalar = inputs[1][0];
matlab::data::CharArray inChar = inputs[2];
result = ...
outputs[0] = result;
}begin
iterator_type begin()Returns an iterator pointing to the first element in the
ArgumentList array.
|
|
Iterator pointing to the first element in the
|
Build a vector from the input arguments.
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
std::vector<matlab::data::TypedArray<double>> vectorDoubles(inputs.begin(), inputs.end());
...
}end
iterator_type end()Returns an iterator pointing past the last element in the
ArgumentList array.
|
|
Iterator pointing past the last element in the
|
size
size_t size()Returns the number of elements in the argument list. Use to check the number of inputs and outputs specified at the call site.
|
|
Size of the |
Determine if the MEX function is called with three input arguments.
class MexFunction : public matlab::mex::Function {
public:
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
if (inputs.size() == 3) {
// MEX function called with three input arguments
...
}
}empty
bool empty()Returns logical value indicating if argument list is empty.
| Returns logical |
Determine if the MEX function is called with no input arguments.
class MexFunction : public matlab::mex::Function {
public:
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
if (inputs.empty()) {
// MEX function called with no input arguments
...
}
}Version History
Introduced in R2018a