ClearAll[f]
For[i = 1, i <= 20, i++,
f[x_, y_, z_] := 2 x + y + z;
data = RandomReal[{-1, 1}, {i, 3}];
mapping = Map[f @@ # &, data]
mapping[[i]]]
In the above code, I want to run the loop 20 times, each time with different sets of random numbers, and finally print out the 20 values in the form of mapping [[i]]
. Clearly I am not achieving that. Can anyone help me please?
;
before the lastmapping
, also,For
does not return so you needPrint
. $\endgroup$i
rows, map every one but use onlyi-th
, was that the goal? $\endgroup$Table[f @@ RandomReal[{-1, 1}, 3], 20]
orf @@@ RandomReal[{-1, 1}, {20, 3}]
. $\endgroup$