How to use output variables with COM objects?

1 回表示 (過去 30 日間)
Andrew
Andrew 2016 年 12 月 2 日
コメント済み: Guillaume 2016 年 12 月 2 日
I am currently trying to writing a program using an API within MATLAB. This API uses a lot of output variables within its methods. I'm currently trying to use the invoke method for most of my calls but it does not support Output variables, is there another MATLAB method that I should be using?

回答 (1 件)

Guillaume
Guillaume 2016 年 12 月 2 日
Using invoke to call COM methods is not recommended and certainly can't be used for functions that have multiple [out] parameters. You can just call the method with the standard dot notation and get all the outputs the standard matlab way.
This page shows an example of calling a method with multiple [out] parameters (see TestMethod3).
Note: use invoke(COMobjecthandle) to see the exact in/out signature that matlab expects for all the methods of COMobjecthandle.
  2 件のコメント
Andrew
Andrew 2016 年 12 月 2 日
I'm not able to use dot notation because MATLAB does not fully recognize the applications type library. Is there any way to add the .tlb file to MATLAB's references?
Guillaume
Guillaume 2016 年 12 月 2 日
As far as I know, it's not possible to specify a .tlb for a COM object in matlab. You may be better off raising a service request to mathworks to know for sure.
Does that mean that your COM class hasn't got an IDISPATCH interface? (or it's only partly implemented). Can it be recompiled with the full interface?
Otherwise, a less than ideal option, is to write a .Net wrapper and communicate through .Net. It's been a while since I've written COM or .Net code so I don't remember how to do this anymore, but iirc, it's not particularly complicated.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeUse COM Objects in MATLAB についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by