how to execute string variable?

77 vues (au cours des 30 derniers jours)
Andika
Andika le 12 Juil 2012
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?

Réponse acceptée

TAB
TAB le 12 Juil 2012
xxx = strcat('x0=5;','a=2;','c=x0+a;');
eval(xxx);
  2 commentaires
Andika
Andika le 12 Juil 2012
thank you very much. I have tried it, and it worked well
Jan
Jan le 12 Juil 2012
On the other hand, Andika, avoiding EVAL would be a much better idea. Please read the hundrets of related threads in this forum.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Identification dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by