How can I preprocess a value assigned to a variable?

I want something like that:
for variable_number=1:3
var_< variable_number > = variable_number;
end
The result should be the creation of 3 variables:
  • var_1 = 1
  • var_2 = 2
  • var_3 = 3
I want that MATLAB first process the < variable_number > and then process the equation.

답변 (2개)

ES
ES 2013년 11월 5일

0 개 추천

you can use eval(['var_',num2str(variable_number),'=',num2str(variable_number)])
But as pointed out in the link shared above, it is very very inefficient. More so, given that Matlab works on arrays and matrices.

카테고리

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

질문:

2013년 11월 5일

답변:

ES
2013년 11월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by