Acquiring related Matrix Members
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a n by m matrix A and 1 by n array B. Assume
A = rand(3,5)
B = [3;5;2]
How can I get 1st rows 3rd element, 2nd rows 5th element and 3rd rows 2. element of A matrix w/o for loop?
Each rows related element is the member of B array as you can see?
댓글 수: 0
채택된 답변
추가 답변 (1개)
Andrei Bobrov
2012년 8월 7일
편집: Andrei Bobrov
2012년 8월 7일
out = A(sub2ind(size(A),(1:numel(B))',B(:)));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!