Calling an object method where the name of the method is a varible

1 回表示 (過去 30 日間)
Eric
Eric 2019 年 1 月 25 日
コメント済み: Eric 2019 年 1 月 25 日
I am trying to call an object method when I have the object instance, the method name, and the argument value(s) as variables. If my object were a COM object, I could use invoke(). Is there something similar to this for user-defined classes? I'm trying to avoid using eval().

採用された回答

Matt J
Matt J 2019 年 1 月 25 日
You can just do,
object.(methodname)(arg1,arg2,...)
  1 件のコメント
Eric
Eric 2019 年 1 月 25 日
Thanks! I didn't realize the dynamic field name syntax for structures also works for objects.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by