Ok, so I have an object as a property of a class. This object has methods. I need to use an object's method as a handle, like follows:
classdef MyClass properties my_obj_with_methods end methods function r = foo(obj, func, a, b) r = func(a, b); end function r = bar(obj) r = obj.foo(@obj.my_obj_with_methods.my_method, 1, 2); end function r = foobar(obj) r = obj.foo(@obj.my_obj_with_methods.my_other_method, 1, 2); end endend
When I try to do this, I get:
"Undefined function or variable 'obj.my_obj_with_methods.my_method"
1 – I know I can solve this with an `if/else`, but I thought "hey, Matlab is a functional language, I could use those great functional features!"
2 – I'm not complicating things, I have good reason to want to do this
Thanks!
Best Answer