How do i use str2func for methods within a class?
이전 댓글 표시
I have a class with several functions. Now I want to write a new function within this class that has an string as an input. This string is an actual function name that is defined within that same class. The new function has to convert this string to the function handle and run this particular function. I tried to do this conversion using str2func, however it doesnt recognize the function: Undefined function or variable 'obj.calcMassMatrixTot'.. However, when I try a global Matlab function such as rand, it works. So it looks like str2func can only see functions that are defined globally. How should I approach this problem?
edit: it might be important to note that im creating the function handle in a function within a different class.
edit2: solved it by moving the new function to the class where i am running all the functions. Still i wonder how i could make the right function handle.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Function Handles에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!