zz=indexvariant([vec,dim])
vec : | row or col vector; default is [1 2 3] | |
dim : | integer as dimension; default is 2 |
zz : | index field [numel(vec)^dim x dim] |
zz=indexvariant([1:3],1); zz, whos zz
zz=indexvariant([1:3],2); zz, whos zz
zz=indexvariant([1:3],3); zz, whos zz
zz=indexvariant([1:3],4); zz, whos zz
This function, indexvariant
, generates multidimensional index sequences. It is designed to be faster than permutevector
and is part of the SolidGeometry library.
[1 2 3]
.2
.[numel(vec)^dim x dim]
.vec
and dim
using the getfuncparams
function. If not provided, use default values.dim
by subtracting 1 to align with zero-based indexing.vec
is a row vector, transpose it to a column vector.zz
with vec
.dim
:zz
n
times using repmat
and store in oo
.vec
n^k
times, reshape it, and store in uu
.uu
to have dimensions [n^(k+1), 1]
.oo
and uu
to form the new zz
.Examples of how to use the function:
zz=indexvariant([1:3],1);
zz=indexvariant([1:3],2);
zz=indexvariant([1:3],3);
zz=indexvariant([1:3],4);