I want to convert a string to .m file

6 ビュー (過去 30 日間)
Osama Alkurdi
Osama Alkurdi 2020 年 2 月 2 日
コメント済み: Osama Alkurdi 2020 年 2 月 2 日
ex: (for understand what I mean clearly)
if I have a string stored in some variable
let's say y="x=sin(pi)";
I want matlab to create a .m file with a certain name a save that string in it
so, the string will be a command line in that .m fileCapture.PNG
  4 件のコメント
Osama Alkurdi
Osama Alkurdi 2020 年 2 月 2 日
@stozaki
yes, but I want to excute it from .m file
Osama Alkurdi
Osama Alkurdi 2020 年 2 月 2 日
@Sridhar SG 8
no

サインインしてコメントする。

採用された回答

stozaki
stozaki 2020 年 2 月 2 日
編集済み: stozaki 2020 年 2 月 2 日
Please try following script. (attached .m file)
y="x=sin(pi)";
eval (y)
eval execute MATLAB expression in text.
Regards,
stozaki
  1 件のコメント
Osama Alkurdi
Osama Alkurdi 2020 年 2 月 2 日
thank you very much :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by