Effacer les filtres
Effacer les filtres

Accessing a cell in a 2D grid

1 vue (au cours des 30 derniers jours)
Lama Hamadeh
Lama Hamadeh le 3 Juil 2021
Commenté : dpb le 4 Juil 2021
Hi all,
I have a 2D grid as shown below where each cell represents a pair of and where and . I would like to construct a new index that combines these two indices to run over all of the cells as a one continous number.
Any help would be appreciated.

Réponses (1)

Cris LaPierre
Cris LaPierre le 3 Juil 2021
Consider using linear indexing. You can find an explanation towards the middle of this page. It is also explained here. If you need to go back and forth between a linear index and row/column indexing, you can use the functions ind2sub and sub2ind.
  6 commentaires
Lama Hamadeh
Lama Hamadeh le 4 Juil 2021
That is amazing! Many thanks for that!
dpb le 4 Juil 2021
Yet again, however, I'd almost wager it isn't the most fruitful approach to the problem...

Connectez-vous pour commenter.


En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by