String to a mathematical expression

6 ビュー (過去 30 日間)
Elia
Elia 2013 年 12 月 22 日
コメント済み: Elia 2013 年 12 月 23 日
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 日
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 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by