FUNCTION REFERENCE
ind2sub
Convert linear indices to subscripts.
Convert linear indices to subscripts.
Syntax
ind = ind2sub(siz, ind)Syntax
[I, J] = ind2sub(siz, ind)Syntax
[I1, I2, ..., In] = ind2sub(siz, ind)With fewer outputs than dimensions the last output spans the remaining dimensions;
extra outputs are 1. One output returns the linear index itself.
As in MATLAB there is no range check: the last output absorbs any overflow
([r, c] = ind2sub([3 4], 13) gives r = 1, c = 5). siz may be a single number.
Example
[r, c] = ind2sub([3 4], [5 7 12]) % r = [2 1 3], c = [2 3 4]Differences from MATLAB: none known for double indices.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.