How to select rows from an array?
이전 댓글 표시
I have matrix of A
. I need to select the 2nd, 4th and 6th row. How can I write that in MATLAB code?
답변 (3개)
ANANTA BIJOY BHADRA
2022년 10월 12일
1 개 추천
댓글 수: 1
Casey
2024년 5월 8일
Thank you for posting, this was helpful.
Torsten
2022년 10월 12일
B = [A(2,:);A(4,:);A(6,:)]
or if you want the rows one by one:
A2 = A(2,:);
A4 = A(4,:);
A6 = A(6,:);
See this page of the doc to learn about array indexing.
Hint: A(__,:) where the blank is a vector of row indicies.
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!