I have a matrix whose dimensions are 26x26x3. For my assignment I have written a program which is using a Do
loop (maxx=maxy=10,maxz=2):
Do[
n = 0;
h=0.4;
k = Table[
If[a <= #1 <= a + h && b <= #2 <= b + h && c <= #3 <= c + h & @@ pts[[w, t]], 1, 0],
{w, 1, Length[pts]},
{t, 1, Length[pts[[w]]]}
];
pls = Plus @@@ k;
For[i = 1, i <= Length[pls], i++, If[pls[[i]] > 0, n++]];
n,
{a, 1, maxx, h}, {b, 1, maxy, h}, {c, 1, maxz, h}
]
At every iteration I get a new value for n and I have to assign it to the correct position of my matrix as efficiently and fast as possible. I don't have a counter. So, I am a bit confused. How can I solve this issue?
On the other hand, can I create a matrix by saving n at the end of the Do
loop?
Any help is appreciated.