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?

 채택된 답변

TAB
TAB 2012년 7월 12일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2012년 7월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by