how to execute string variable?

can i do this in matlab? %first i want to make a variable named = xxx, and xxx contains MATLAB commands just like this:
xxx = strvcat('x0=5','a=2','c=x0+a')
%but when I use eval, it doesn't work eval(xxx)
Anyone can help me?

 Respuesta aceptada

TAB
TAB el 12 de Jul. de 2012

0 votos

xxx = strcat('x0=5;','a=2;','c=x0+a;');
eval(xxx);

2 comentarios

Andika
Andika el 12 de Jul. de 2012
thank you very much. I have tried it, and it worked well
Jan
Jan el 12 de Jul. de 2012
On the other hand, Andika, avoiding EVAL would be a much better idea. Please read the hundrets of related threads in this forum.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de Jul. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by