I have a COM object named "objPoints3d" and want to call it from Matlab. What is the matlab equivalent to pass an array? I try this and get:
>> objPoints3d.Add(3,[1,2,3])
Error using Interface.6F7F088F_F1F5_4B76_81D2_44D9A7A2A1ED/Add
Invoke Error, Dispatch Exception: Ungültiger Zeiger
(Invoke Error, Dispatch Exception: invalid pointer)
...which is at least already different from passing a scalar instead of an array:
>> objPoint3d1 = objPoints3d.Add(3, 1)
Interface.6F7F088F_F1F5_4B76_81D2_44D9A7A2A1ED/Add
Error: Type mismatch, argument 2
So, at least somehow the COM object recognizes the array, but not really.
The method is definded like this, according to the documentation:
Public Function Add( _
ByVal NumberOfValues As Long, _
ByRef Array() As Double _
invoke delivers this:
Item = handle Item(handle, Variant)
Add = handle Add(handle, int32, SafeArray(double))
GetPointByIndex = SafeArray(double) GetPointByIndex(handle, uint32_T)
GetPointByPosition = uint32_T GetPointByPosition(handle, double, double, double)
GetDispatchByIndex = SafeArray(double) GetDispatchByIndex(handle, uint32_T)
Style = handle Style(handle, int32)
SetStyle = void SetStyle(handle, int32, handle)
Edit = void Edit(handle, int32, int32, SafeArray(double))
So, here the method definition is documented as Add = handle Add(handle, int32, SafeArray(double)). And this delivers:
>> methods(objPoints3d,'-full')
Methods for class Interface.6F7F088F_F1F5_4B76_81D2_44D9A7A2A1ED:
handle Add(handle, int32, SafeArray(double))
Edit(handle, int32, int32, SafeArray(double))
SafeArray(double) GetDispatchByIndex(handle, uint32_T)
SafeArray(double) GetPointByIndex(handle, uint32_T)
uint32_T GetPointByPosition(handle, double, double, double)
handle Item(handle, Variant)
SetStyle(handle, int32, handle)
handle Style(handle, int32)
addproperty(handle, string)
delete(handle, MATLAB array)
deleteproperty(handle, string)
MATLAB array events(handle, MATLAB array)
MATLAB array get(handle, MATLAB array, MATLAB array)
MATLAB array get(handle vector, MATLAB array, MATLAB array)
MATLAB array invoke(handle)
MATLAB array invoke(handle, string, MATLAB array)
MATLAB array loadobj(handle)
release(handle, MATLAB array)
MATLAB array saveobj(handle)
MATLAB array set(handle, MATLAB array, MATLAB array)
MATLAB array set(handle vector, MATLAB array, MATLAB array)
In Visual Basic I can successfully call this method with this:
Dim dblArray(0 To 3) As Double
objPoint3d1 = objPoints3d.Add(3, dblArray)
Even if I try to pass back the output of above Method: SafeArray(double) GetPointByIndex(handle, uint32_T)), I get the same:
>> a=objPoints3d.GetPointByIndex(0)
Error using Interface.6F7F088F_F1F5_4B76_81D2_44D9A7A2A1ED/Add
Invoke Error, Dispatch Exception: Ungültiger Zeiger
Actually, I'd suppose, a should now have the exact Type that the Add method wants: SafeArray(double).
I can successfully invoke a similar method of a different object from matlab:
objLine3d1 = objLines3d.Add(-0.1, 0.03, 0.05, 0.05, 0.06, 0.07)
But there the parameters are all scalars, defined like this:
Public Function Add( _
ByVal Startx As Double, _
ByVal Starty As Double, _
ByVal Startz As Double, _
ByVal Endx As Double, _
ByVal Endy As Double, _
ByVal Endz As Double _