tilerowcol
Gives the row and column of a tile, given its number in a tiled layout.
Category: Graphics > Formatting and Annotation
Syntax
[row, col] = tilerowcol(t, n)
Returns the row and column of tile n in layout t.
Description
It inverts tilenum. For a layout with c columns, tile n is in row ceil(n/c) and column mod(n - 1, c) + 1. The function is useful when a loop runs over tile numbers and the position of each is needed, for example to label only the outer tiles.
Input arguments
t- Layout created by
tiledlayout. n- Tile number, a positive integer counted along rows.
Output arguments
row, col- Position of the tile in the grid, counted from 1.
Example
Where is tile 5?
t = tiledlayout(2, 3);
[r, c] = tilerowcol(t, 5)
[r, c] = tilerowcol(t, 6)
Output
r = 2
c = 2
r = 2
c = 3