I want to convert a string to .m file

6 次查看(过去 30 天)
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

请先登录,再进行评论。

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by