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. ???
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!