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 CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by