MATLAB Answers


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

Asked by Eric
on 25 Jan 2019
Latest activity Commented on by Eric
on 25 Jan 2019
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().


Sign in to comment.


1 Answer

Answer by Matt J
on 25 Jan 2019
 Accepted Answer

You can just do,

  1 Comment

Thanks! I didn't realize the dynamic field name syntax for structures also works for objects.

Sign in to comment.