Documentation Center

  • Trial Software
  • Product Updates

Pass Pointers

Pass Primitive MATLAB Type

MATLAB® automatically converts an argument passed by value into an argument passed by reference when the external function prototype defines the argument as a pointer. For example, a MATLAB double argument passed to a function that expects double * is converted to a double pointer by MATLAB.

addDoubleRef is a C function that takes an argument of type double *.

 addDoubleRef C Function

Call the function with three arguments of type double, and MATLAB handles the conversion:

calllib('shrlibsample','addDoubleRef',1.78,5.42,13.3)
ans =
   20.5000
Was this topic helpful?