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 日

1 投票

[tf idx] = ismember(B,A(:,1:3),'rows')

3 件のコメント

Rinu
Rinu 2014 年 5 月 31 日
編集済み: Rinu 2014 年 5 月 31 日
I think that command only tells whether the rows of B occur in A or not. In this case, all the rows of B occur in A, but I want to find the exact location where it occurs so that I can extract the fourth column value (elevation) of the larger matrix and paste it to a fourth column in the smaller matrix. Thanks anyways.
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 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2014 年 5 月 31 日

コメント済み:

2014 年 5 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by