String to a mathematical expression

how can i convert a String to a mathematical expression , that i can use in a function's body ?

2 Comments

That depends. What does the String look like?
for example sin(x)-x^2

Sign in to comment.

 Accepted Answer

Matt J
Matt J on 22 Dec 2013
If you display the string at the command line, you can then copy/paste it into the function's body.

2 Comments

i want to get the string from an edit text feld in a gui . it will be a function's body that i want to plot it .
If the string will always be a function of a known letter, e.g. 'x', you can do
theFunc = str2func(['@(x)' theString])

Sign in to comment.

More Answers (0)

Categories

Asked:

on 22 Dec 2013

Commented:

on 23 Dec 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!