MATLAB: What can be passed to an ActiveX object using INVOKE

acitvexactiveactivexactxarraycontrolinvokeMATLABolevariantvariantsx

I have an ActiveX object which I've instantiated inside MATLAB. I want to invoke a method, but I don't know what I can pass to it. I would like to know what types of arguments the ActiveX method INVOKE currently supports.

Best Answer

In MATLAB you should be able to pass the following to ActiveX controls: scalars, vectors, and matrices of doubles or strings; ActiveX objects; and cell arrays. There is a limitation on cell arrays which are passable. They must have two or fewer dimensions and can contain only scalars or strings. The cell arrays are converted to ActiveX SAFEARRAYs before being passed to the control.
Also, note that one-dimensional arrays in MATLAB are passed as two-dimensional arrays to ActiveX servers.
To see how to pass cell arrays to a control or automation server, let's try it out with the MWSamp control which ships with MATLAB. First, instantiate the control with the MWSAMP command:
mwsamp
Then use INVOKE to pass the cell array:
invoke (h, 'SetBSTRArray', {'asdf',8})
You should see that the control returns a cell array back to MATLAB which contains the same contents which were passed. The SetBSTRArray method takes a SAFEARRAY of Variants and returns a copy as a SAFEARRAY. This SAFEARRAY is converted back into a cell array.
The MWSamp control contains other methods which allow you to pass it any of the data types which MATLAB supports for ActiveX. In MATLAB 5.2 you can type "invoke(h)" to see a full list of the control's methods.