フィルターのクリア

How can I assign a single value (index) for each point in a square?

3 ビュー (過去 30 日間)
Gabriel González
Gabriel González 2012 年 9 月 5 日
I have a geometrical square with MxN dimensions and I need to assign for each pairs of points (x,y) a single index or value.
I've tried doing Index=mY+X but when X is too large index starts to repeat and there are no more single.
i.e m=2; Index=6=2*2+2 and also Index=6 when Index=2*1+4.
I need that every index be unique for each pair of x,y
Cheers!

採用された回答

Oleg Komarov
Oleg Komarov 2012 年 9 月 5 日
編集済み: Oleg Komarov 2012 年 9 月 5 日
You can use sub2ind()
sub2ind([M,N], x,y)
  2 件のコメント
Matt Fig
Matt Fig 2012 年 9 月 5 日
If OP is talking about a patch on R^2, then it cannot be done. If there is a certain spacing involved, such that for any successive pair (x1,y1) & (x2,y2), x2 = x1 + c or y2 = y1 + d or both, then something like SUB2IND will work.
Gabriel González
Gabriel González 2012 年 9 月 5 日
Genius! ajaj thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by