| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Embedded MATLAB |
| Contents | Index |
[y =] eml.ceval('function_name', eml.ref(arg), ... un)
Variable passed by reference as an input or an output to the external C function called in eml.ceval.
[y =] eml.ceval('function_name', eml.ref(arg), ... un) passes the variable arg by reference as an input or an output to the external C function called in eml.ceval. You add eml.ref inside eml.ceval as an argument to function_name. The argument list can contain multiple eml.ref constructs. Add a separate eml.ref construct for each argument that you want to pass by reference to function_name.
Only use eml.ref in Embedded MATLAB code that you have compiled with emlmex or emlc. eml.ref generates an error in uncompiled M-code.
In the following example, an Embedded MATLAB function fcn has a single input u and a single output y. fcn calls a C function my_fcn, passing u by reference as an input. The value of output y is passed to fcn by the C function through its return statement.
Here is the Embedded MATLAB function code:
function y = fcn(u)
y = 0; %Constrain return type to double
y = eml.ceval('my_fcn', eml.ref(u));The corresponding C function prototype looks like this:
real_T my_fcn(real_T *a)
In this example, the Embedded MATLAB subset infers the type of the input u from its definition in the parent model.
The C function prototype defines the input as a pointer because it is passed by reference.
Embedded MATLAB cannot infer the type of the output y, so you must set it explicitly—in this case to a constant value 0 whose type defaults to double, matching the C type real_T. For a list of type mappings, see Mapping MATLAB Types to C.
![]() | eml.opaque | eml.rref | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |