| 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.rref(argI), ... un)
Variable passed by reference as a read-only input to the external C function called in eml.ceval.
[y =] eml.ceval('function_name', eml.rref(argI), ... un) passes the variable argI by reference as a read-only input to the external C function called in eml.ceval. You add eml.rref inside eml.ceval as an argument to function_name. The argument list can contain multiple eml.rref constructs. Add a separate eml.rref construct for each read-only argument that you want to pass by reference to function_name.
Caution Embedded MATLAB assumes that a variable passed by eml.rref is read-only and optimizes the code accordingly. Consequently, the C function must not write to the variable or results can be unpredictable. |
Only use eml.rref in Embedded MATLAB code that you have compiled with emlmex or emlc. eml.rref 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 foo, passing u by reference as a read-only 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('foo', eml.rref(u));The corresponding C function prototype looks like this:
real_T foo(real_T *a)
In this example, Embedded MATLAB 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.ceval, eml.opaque, eml.ref, eml.wref
![]() | eml.ref | eml.target | ![]() |

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 |