I understand that all the returned values of a mex function are stored in plhs array of type mxArray*. I want to return a value of type float. How can I do it?
Some code examples on returning it from the mex function and retrieving it from the m-file is much appreciated.
The MATLAB class name for float type data is "single".
In the MEX-file you could write:
Retrieving it from the M-file is pretty much like calling any other function. If you named the MEX-function
foo
, you'd call it like this:Now
x
would contain the single-precision value equivalent tosingle([1 2 3; 4 5 6])
that was stored inplhs[0]
.