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
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 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!