Creating vector from another vector containing 2x2 matrix indices
조회 수: 2 (최근 30일)
이전 댓글 표시
I have an MxN matrix A. I can find the minimum of values in each column of A by: [Amin imin]=min(A(1:end),:) where imin is the line index of the minimum in each column (imin=[1 4 2 2 4 5 4 4] in example below). This way I get the array imin that contains these line indices. Now I want to find the equivalents of these elemts in another MxN matrix B (red boxes in picture below) and create a new vector V in the form: V= [B11 B42 B23 B24 B45 B56 B47 B48]
댓글 수: 0
채택된 답변
Andrei Bobrov
2017년 10월 20일
편집: Andrei Bobrov
2017년 10월 20일
[~,ii] = min(A);
V = B(sub2ind(size(A),ii,1:size(A,2)));
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!