'Typecasting' COM-objects in matlab?
3 views (last 30 days)
Show older comments
Is it possible to typecast COM objects in matlab, as would be done in C# for instance?
I am using a COM dll (actxserver).
The code in C# of what I want to do is:
var m = tracker.Measurement.MeasureStationary() as StationaryMeasurement3D;
The object returned by 'tracker.Measurement.MeasureStationary()' is not of type 'StationaryMeasurement3D', but can be cast to it.
I've tried using the cast() function in matlab, but returns with the error 'Unsupported data type for conversion'.
0 Comments
Answers (1)
Guillaume
on 9 Oct 2015
Use invoke to get access to a different interface implemented by the com object. The list of interfaces implemented by that object can be obtained with interfaces.
3 Comments
Guillaume
on 12 Oct 2015
Edited: Guillaume
on 12 Oct 2015
It may well be a limitation of matlab in which case I'm not sure there's any workaround (short of rewriting the com object).
Note that the documentation states that "custom interfaces are not supported on a 64-bit version of MATLAB". I've not got a 32-bit version installed anymore so can't really do any testing. It's also been a while since I've dealt with COM since I never bothered upgrading my COM components to 64-bit.
Is there a way to access the com interface you want through an IDISPATCH interface (obtained via a property of the object)?
See Also
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!