Problem for creating matrix with loop
이전 댓글 표시
A=[1 2 3;4 5 6;7 8 9]
%I wanna create a loop like that
for i=2:3
A(1:i,:)
end
%What I'm trying to do is getting these matrixes from the loop,
A_1= A(2:2,:)
A_2= A(3:2,:)
For retrieve these matrixes from the loop, what equation I should write in the loop?
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2014년 1월 15일
편집: Azzi Abdelmalek
2014년 1월 15일
What is the purpose of creating other variables, when you can access any part of your matrix, whenever you want.
If you want A(2:2,:) , you don't need to create a variable A_1, just write
A(2:2,:)
Or you can create a cell array B
B{1}=A(2:2,:)
B{2}=A(3:2,:)
댓글 수: 3
sermet
2014년 1월 15일
sermet
2014년 1월 15일
편집: Azzi Abdelmalek
2014년 1월 15일
Azzi Abdelmalek
2014년 1월 15일
편집: Azzi Abdelmalek
2014년 1월 15일
k=1;
for i=2:10
k=k+1;
B{k}=A(1:i,:)
end
B{2}
B{3}
카테고리
도움말 센터 및 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!