ind2sub
Convert an index for an array to subscripts.
sub=ind2sub(arraysize,ind)
[j,k,l,..]=ind2sub(arraysize,ind)
Inputs
arraysize The size of the array.
ind An scalar integer index for the array.
Outputs
sub The vector of subscripts such that for any array x of size arrayszie , x[ind] and x[sub[1],sub[2],sub[3],...] are identical, being the value of the same element in the array.
{j, k,..} The elements of the vector of subscripts (returned by the first form) such that for any array x of size arrayszie , x[ind] and x[j, k, l, ...] are identical, being the value of the same element in the array.


Example
>>a=rand(2,4,3)
>>ind2sub(size(a),13)
     1   3    2 
>>a[13]==a[1,3,2]
         1