필터 지우기
필터 지우기

get the value of element from matrix

조회 수: 1 (최근 30일)
ha ha
ha ha 2019년 5월 17일
편집: Stephen23 2019년 5월 17일
Let's say: I have matrix A, B
A=[1 1 200; 2 2 2;9 9 9; 5 5 5; 3 3 355];%matrix 5x3
B=[9 9; 1 1; 3 3]%matrix 3x2
How can I call the result matrix somehow the value of two first column in matrix A is the same as in matrix B?
result=[9 9 9; 1 1 200; 3 3 355];

채택된 답변

Stephen23
Stephen23 2019년 5월 17일
편집: Stephen23 2019년 5월 17일
Simply use ismember and basic MATLAB indexing:
>> [X,Y] = ismember(B,A(:,1:2),'rows');
>> Z = A(Y(X),:)
Z =
9 9 9
1 1 200
3 3 355

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by