I want to convert a string to .m file

6 visualizaciones (últimos 30 días)
Osama Alkurdi
Osama Alkurdi el 2 de Feb. de 2020
Comentada: Osama Alkurdi el 2 de Feb. de 2020
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 comentarios
Osama Alkurdi
Osama Alkurdi el 2 de Feb. de 2020
@stozaki
yes, but I want to excute it from .m file
Osama Alkurdi
Osama Alkurdi el 2 de Feb. de 2020
@Sridhar SG 8
no

Iniciar sesión para comentar.

Respuesta aceptada

stozaki
stozaki el 2 de Feb. de 2020
Editada: stozaki el 2 de Feb. de 2020
Please try following script. (attached .m file)
y="x=sin(pi)";
eval (y)
eval execute MATLAB expression in text.
Regards,
stozaki

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by