Find elements in a matrix
1 次查看(过去 30 天)
显示 更早的评论
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".
0 个评论
采纳的回答
the cyclist
2014-5-31
编辑:the cyclist
2014-5-31
[tf idx] = ismember(B,A(:,1:3),'rows')
3 个评论
the cyclist
2014-5-31
编辑:the cyclist
2014-5-31
The second output of the ismember command gives the index to the corresponding row.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!