How do I convert a string input to an executable equation?
Afficher commentaires plus anciens
I am developing a nice GUI for my company (those who don't want to code). It will give them areas to add their equations and define their constants, blah blah blah. The challenge I'm running into is grabbing the input string from the user and converting that to an executable equation or expression. Any thoughts?
1 commentaire
Réponse acceptée
Plus de réponses (2)
Joseph Cheng
le 13 Mar 2014
Modifié(e) : Joseph Cheng
le 13 Mar 2014
Depending on what their equation uses eval (see http://www.mathworks.com/help/matlab/ref/eval.html) might work. if i remember correctly some toolboxes and functions are not supported if your GUI is compiled into a standalone. So put the edit box string into the eval
eval(get(handles.editbox1,'String'));
2 commentaires
Chris C
le 13 Mar 2014
sangeet pillai
le 24 Fév 2017
thank you joseph.your answer saved me a lot of time
Karan Gill
le 29 Sep 2017
Modifié(e) : Karan Gill
le 17 Oct 2017
>> syms f(x)
>> function1 = input('Please enter the function: ', 's');
Please enter the function: sin(x)
>> f(x) = str2sym(function1)
f(x) =
sin(x)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!