如何在 MATLAB 中获取对象(类 inst)中方法的句柄 [英] How to get the handle of a method in an Object (class inst) within MATLAB

查看:18
本文介绍了如何在 MATLAB 中获取对象(类 inst)中方法的句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从 MATLAB 中的对象中获取方法句柄,但 str2func('obj.MethodName') 之类的东西不起作用

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

推荐答案

也可以写

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

这样做的好处是,如果对象 (obj) 被修改,它不需要句柄类即可工作.

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

这篇关于如何在 MATLAB 中获取对象(类 inst)中方法的句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆