'Typecasting' COM-objects in matlab?
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'.
Answers (1)
Guillaume
on 9 Oct 2015
0 votes
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
Joris Janssenswillen
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)?
Joris Janssenswillen
on 13 Oct 2015
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!