ind2sub
Convert a linear index to N-dimensional subscripts.
Syntax
Section titled “Syntax”[I1, I2, ...] = ind2sub(siz, IND)Description
Section titled “Description”Inverse of sub2ind. Given a size vector siz and one or more linear indices IND, returns matched arrays of subscripts — one output per dimension. Number of outputs is determined by how the call is destructured ([i, j] = … requests two; [i, j, k] = … requests three).
When IND is a vector or matrix, each output has the same shape as IND.
Examples
Section titled “Examples”[i, j] = ind2sub([3 4], 8) % i=2, j=3[i, j] = ind2sub([3 4], [1 5 8]) % i=[1 2 2], j=[1 2 3]