How can I get dynamic naming variables? So in a loop i need variables with names A1,A2,A3...... logic?

1 次查看(过去 30 天)
the loop running should produce N outputs with each having label A1,A2,A3....An

回答(1 个)

CS Researcher
CS Researcher 2016-5-1
You can use eval. Try this:
for i = 1:10
eval(['A' num2str(i) ' = i;']);
end
  2 个评论
Stephen23
Stephen23 2016-5-1
编辑:Stephen23 2019-6-19
Note that this forces you into writing slow, buggy, obfuscated code, that removes all of MATLAB code checking abilities and makes code difficult to debug.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by