How to use for loop in this problem

n=3;
b=eye(n);
b1=b(:,1)
b2=b(:,2)
b3=b(:,3)

댓글 수: 2

Stephen23
Stephen23 2022년 4월 26일
편집: Stephen23 2022년 4월 26일
"How to use for loop in this problem"
The main problem I can see is forcing pseudo-indices into variable names. Once beginners start trying to access those variable names dynamically then they force themselves into writing slow, complex, inefficient code trying to access their data:
Basically your bad data design will force you into writing bad code.
What do you think is the problem?
하민 김
하민 김 2022년 4월 26일
thanks for your answer

댓글을 달려면 로그인하십시오.

답변 (1개)

chrisw23
chrisw23 2022년 4월 28일

0 개 추천

Maybe this helps.
tbl = array2table(b);
tbl.b1
tbl.b2
tbl.b3
% see also tbl.Properties

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2022년 4월 26일

답변:

2022년 4월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by