필터 지우기
필터 지우기

Find elements in a matrix

조회 수: 1 (최근 30일)
Rinu
Rinu 2014년 5월 31일
댓글: Rinu 2014년 5월 31일
I have a very large matrix A with 4 columns and hundreds of thousands of rows - the first 3 columns contain x, y and z coordinates and the fourth column contains elevation values. I have another smaller matrix B of 3 columns containing x, y and z coordinates at which I need to extract the elevation values from the larger matrix. How do I search for the particular coordinates (given by B) in the larger matrix A? I tried to use 'find' to extract the indices of every match: >> ind=find(B==A(:,1:3))
but I get the error "Matrix dimensions must agree".

채택된 답변

the cyclist
the cyclist 2014년 5월 31일
편집: the cyclist 2014년 5월 31일
[tf idx] = ismember(B,A(:,1:3),'rows')
  댓글 수: 3
the cyclist
the cyclist 2014년 5월 31일
편집: the cyclist 2014년 5월 31일
The second output of the ismember command gives the index to the corresponding row.
Rinu
Rinu 2014년 5월 31일
Oh Thanks :-)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by