How can I pass arguments by reference to an ActiveX server from MATLAB 7.0 (R14)?
7 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2009-6-27
编辑: MathWorks Support Team
2016-11-28
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.
采纳的回答
MathWorks Support Team
2016-11-28
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!