The default data conversion rules for MATLAB's COM interface convert all non-scalar MATLAB arrays into 2-dimensional SAFEARRAYs.
Beginning with MATLAB 7.0.4 (R14SP2) it is possible to work around the default data conversion rule and have MATLAB convert a MATLAB array into a single dimensional SAFEARRAY. You can pass data to ActiveX servers as one-dimensional arrays by executing the following command at the MATLAB prompt:
After executing this command, MATLAB will convert any single column matrix to a 1 dimensional array when passed to a COM object.
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 as two-dimensional arrays, execute:
You can also query the current state of this property with the command
In the case of the example with the ADODB.Stream object given above, you could use the following code to work around the issue. In this example, the COM_SafeArraySingleDim is only enabled for the single function call where it is required.
sqlstream.Type = 1;
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)
If you are using MATLAB 7.0 (R14) or MATLAB 7.0.1 (R14SP1), you can download a revised version of comcli.dll that allows you to use the work around described above. For the required steps, see the Related Solution "Why am I having problems using the MATLAB 7.0 (R14) COM interface?"