Effacer les filtres
Effacer les filtres

Find elements in a matrix

1 vue (au cours des 30 derniers jours)
Rinu
Rinu le 31 Mai 2014
Commenté : Rinu le 31 Mai 2014
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".

Réponse acceptée

the cyclist
the cyclist le 31 Mai 2014
Modifié(e) : the cyclist le 31 Mai 2014
[tf idx] = ismember(B,A(:,1:3),'rows')
  3 commentaires
the cyclist
the cyclist le 31 Mai 2014
Modifié(e) : the cyclist le 31 Mai 2014
The second output of the ismember command gives the index to the corresponding row.
Rinu
Rinu le 31 Mai 2014
Oh Thanks :-)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by