Print matrices whose name is based on loop values

1 次查看(过去 30 天)
for i = 1:3
eval(['k' num2str(i) '=i']);
end
%% Doubt - How to print k1, k2, k3 based on iteration no. ???

采纳的回答

Steven Lord
Steven Lord 2022-7-21
Can you dynamically create variables with numbered names like k1, k2, k3, etc.? Yes.
Should you do this? The general consensus is no. That Answers post explains why this is generally discouraged and offers several alternative approaches.

更多回答(0 个)

类别

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