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

댓글 수: 2

per isakson
per isakson 2013년 12월 22일
That depends. What does the String look like?
Elia
Elia 2013년 12월 23일
for example sin(x)-x^2

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2013년 12월 22일

2 개 추천

If you display the string at the command line, you can then copy/paste it into the function's body.

댓글 수: 2

Elia
Elia 2013년 12월 22일
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 .
Matt J
Matt J 2013년 12월 22일
편집: Matt J 2013년 12월 22일
If the string will always be a function of a known letter, e.g. 'x', you can do
theFunc = str2func(['@(x)' theString])

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2013년 12월 22일

댓글:

2013년 12월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by