How to get the handle of a method in an Object (class inst) within MATLAB

后端 未结 4 1649
终归单人心
终归单人心 2020-12-10 07:38

I\'m trying to grab a method handle from within an object in MATLAB, yet something in the sort of str2func(\'obj.MethodName\') is not working

4条回答
  •  一个人的身影
    2020-12-10 08:19

    One could also write

    fstr = 'say';
    obj.(fstr)();
    

    This has the advantage that it does not require a handle class to work if the object (obj) is modified.

提交回复
热议问题