Accessing a cell in a 2D grid

조회 수: 3 (최근 30일)
Lama Hamadeh
Lama Hamadeh 2021년 7월 3일
댓글: dpb 2021년 7월 4일
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.
Thanks.

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 7월 3일
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
Lama Hamadeh
Lama Hamadeh 2021년 7월 4일
That is amazing! Many thanks for that!
dpb
dpb 2021년 7월 4일
Yet again, however, I'd almost wager it isn't the most fruitful approach to the problem...

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by