Find values and positions of a matrix referring to another matrix
조회 수: 9 (최근 30일)
이전 댓글 표시
Hi !!! Good day.
I hope you can help me
I have two matrices
A = [2 4 7];
B = [3 4 6
1 5 7
2 8 9
9 2 4];
From the first element of matrix A find position and value in the first column of matrix B
From the second element of matrix A find position and value in the second column of matrix B
From the third element of matrix A find position and value in the third column of matrix B
In the end I will have two vectors;
one with the values 2, 4, 7 and the other with the positions 3, 1, 2
In reality, matrix A is 1 X 18 and matrix B has 720 X 18
Thank you very much for your help.
Regards.
댓글 수: 0
채택된 답변
David Hill
2019년 10월 1일
for i=1:length(A)
C(i)=find(B(:,i)==A(i),1);%will there always be only one match?
end
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!