External Interfaces - The MathWorks - #51

/ 649


catalogue search
P. 51
P. 52
P. 53
P. 54
P. 55
P. 56
P. 57
P. 58
P. 59
P. 60
P. 61
P. 62
P. 63
P. 64
P. 65
P. 66
P. 67
P. 68
P. 69
P. 70
P. 71
P. 72
P. 73
P. 74
P. 75
P. 76
P. 77
P. 78
P. 79
P. 80
P. 81
P. 82
P. 83
P. 84
P. 85
P. 86
P. 87
P. 88
P. 89
P. 90
P. 91
P. 92
P. 93
P. 94
P. 95
P. 96
P. 97
P. 98
P. 99
P. 100


See other catalogues for The MathWorks

Text version of the page
Passing Arguments
[double, c_structPtr] addStructByRef(c_structPtr) double addStructFields(c_struct) c_structPtrPtr allocateStruct(c_structPtrPtr) voidPtr deallocateStruct(voidPtr) doublePtr multDoubleArray(doublePtr, int32) [lib.pointer, doublePtr] multDoubleRef(doublePtr) int16Ptr multiplyShort(int16Ptr, int32) cstring readEnum(Enum1) [cstring, cstring] stringToUpper(cstring)
While these functions are all written in C, libfunctions with the full qualifier displays the MATLAB syntax for calling the C functions.
See "Primitive Types" on page 2-15 for a table of extended MATLAB types (e.g., doublePtr).
General Rules for Passing Arguments
There are some important things to note about the input and output arguments shown in the function listing of the previous section:
• Many of the arguments (like int32, double) are very similar to their C counterparts. In these cases, you need only to pass in the MATLAB types shown for these arguments.
• Some arguments in C (like **double, or predefined structures), are quite different from standard MATLAB types. In these cases, you usually have the option of either passing a standard MATLAB type and letting MATLAB convert it for you, or converting the data yourself using MATLAB functions like libstruct and libpointer. See the next section on "Data Conversion" on page 2-15.
• C input arguments are often passed by reference. Although MATLAB does not support passing by reference, you can create MATLAB arguments that are compatible with C references. In the listing shown above, these are the arguments with names ending in Ptr and PtrPtr.See"Creating References" on page 2-26.
• C functions often return data in input arguments passed by reference. MATLAB creates additional output arguments to return these values. Note that in the listing in the previous section, all input arguments ending in Ptr or PtrPtr arealsolistedasoutputs.
2-11

pageCatalog pdf di En 2012-06-22-01