hi,
i have a fucntion with a matrix that has variables dimensions (depends on a parameter given in input) and i would like to scan all the elements inside, but the fact is that i don't know how to nest many for loops.
let´s make an example: M is a matrix 3 dimensional with length [2,4,6]
i would like to do:
for i1:1=2for i2:1=4for i3:1=6M(i1,i2,i3) = 0;endendend
as you can notice, i need 3 loops, but how to use N loops, with N the number of dimensions of M (N is fixed once that function is called)? i thought about using eval, but it seems not working..
another related question, i would like to access to element M(i1,i2,i3) if N=3 or M(i1,i2,i3,i4,i5) if N=5, should i use eval also in this case, or is there any better solution?
thanks in advance
Best Answer