nextindex#
Purpose#
Returns the index of the next element or subarray in an array.
Format#
- nind = nextindex(ind, orders)#
- Parameters:
ind (Mx1 vector) – indices into an array where \(M <= N\).
orders (Nx1 vector) – orders of an N-dimensional array
- Returns:
nind (Mx1 vector) – the index of the next element or subarray in the array corresponding to orders.
Examples#
// Dimensions of an array
orders = { 3, 4, 5, 6, 7 };
// Starting index
ind = { 2, 3, 5 };
// Return the index for the next element
nind1 = nextindex(ind, orders);
After the code above, nind1 will be equal to:
2
4
1
In this example, nextindex()
incremented ind to index the next 6x7 subarray in array a.
Using the same data from above, a subsequent call to nextindex()
:
nind2 = nextindex(nind1, orders);
will assign nind2 to be equal to:
2
4
2
Remarks#
nextindex()
will return a scalar error code if the index cannot be incremented.
See also
Functions previousindex()
, loopnextindex, walkindex()