vlookup type matrix creating
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I would like to create a vlookup (excel) type operation that searches matrix A in matrix B and creates matrix C. How could I do it please in the most easy way?
A = [0 0 1 0.25;
0 1 1 0.75]
B = [0 0 1;
0 1 1;
0 1 1;
0 0 1;]
C = [0 0 1 0.25;
0 1 1 0.75;
0 1 1 0.75;
0 0 1 0.25;]
Thank you for any ideas!
댓글 수: 0
채택된 답변
Steven Lord
2020년 2월 13일
Since this sounds like it might be a homework question, I'm only going to point you in the direction of a useful function: ismember (with the 'rows' option.)
댓글 수: 0
추가 답변 (1개)
Rafael Schwarzenegger
2020년 2월 14일
댓글 수: 1
Stephen23
2020년 2월 14일
The MATLAB way:
>> [~,X] = ismember(B,A(:,1:3),'rows');
>> C = A(X,:)
C =
0.00000 0.00000 1.00000 0.25000
0.00000 1.00000 1.00000 0.75000
0.00000 1.00000 1.00000 0.75000
0.00000 0.00000 1.00000 0.25000
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!