How do i use str2func for methods within a class?
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Function Handles dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!