How can I pass arguments by reference to an ActiveX server from MATLAB 7.0 (R14)?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 27 de Jun. de 2009
Editada: MathWorks Support Team
el 28 de Nov. de 2016
I have created an ActiveX server that I instantiate in MATLAB with ACTXSERVER. It appears that MATLAB passes a copy of all data to server methods that I invoke. Instead, I would like to pass data by reference.
Respuesta aceptada
MathWorks Support Team
el 28 de Nov. de 2016
The default data conversion rules for MATLAB's COM interface specifies that arrays are passed by value.
Beginning with MATLAB 7.0.4 (R14SP2) it is possible to work around the default data conversion rule and have MATLAB pass the array by reference. You can pass SAFEARRAYs to ActiveX servers by reference by executing the following command at the MATLAB prompt:
feature('COM_PassSafeArrayByRef', 1)
Note that setting this feature may break COM interaction with Excel, including Excel Link. If you wish to reset the default behavior of MATLAB of passing all data by value, execute:
feature('COM_PassSafeArrayByRef', 0)
You can also query the current state of this property with the command
feature('COM_PassSafeArrayByRef')
Note on passing Numeric arrays by reference: MATLAB supports passing a VARIANT type by reference to COM object. Since cell arrays are converted as SAFEARRAY of VARIANT's, COM_PassSafeArrayByRef works only with cell arrays. Numeric arrays are passed by reference only if they are marked as [in,out] or [out] in the COM object's IDL file.
More information about the default behavior of the MATLAB COM Interface data conversion is available here:
MATLAB COM Client Support :: COM and DDE Support (Windows Only) (External Interfaces)
<http://www.mathworks.com/help/releases/R14/techdoc/matlab_external/ch07cli5.html?s_tid=srchtitle>
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Use COM Objects in MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!