how to execute string variable?

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

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by