Replacing elements of a nested list by some value
Another interesting approach:
i = 0;
Map[0 # + (20 + 0.1 i++) &, A]
{{20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20.}, {20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1}, {20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2}, {20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3}}
ClearAll[miF, rPF, tBF];
miF = MapIndexed[20 + .1 (#2[[1]] - 1) &, #, {2}] &;
or
rPF = ReplacePart[#, {i_, _} :> (19.9 + 0.1 i)] &;
or
tbF = Block[{j = 0}, Table[ 0 i + 20 + 0.1 j++, {i, #}]] &;
Example:
A = {{0.620161, 0.320312, 0.94842, 1.11844, 1.12045, 1.12539, 1.13177,
1.13142, 1.15048, 1.23244, 0.721388, 0.708943, 0.750067,
0.744916, 0.720972, 0.674833, 1.29773, 1.29514}, {0.620161,
0.320312, 0.94842, 1.11844, 1.12045, 1.12539, 1.13177, 1.13142,
1.15048, 0.721388, 0.750067, 0.744916, 0.720972, 0.674833,
1.29383, 1.29514}, {0.620161, 0.320312, 0.94842, 1.11844, 1.12045,
1.12539, 1.13177, 1.13142, 1.15048, 0.721388, 0.750067, 0.744916,
0.720972, 0.674833, 1.29383, 1.29514}, {0.620161, 0.320312,
0.94842, 1.11844, 1.12539, 1.13177, 1.13142, 1.15048, 0.721388,
0.750067, 0.744916, 0.720972, 0.674833, 1.29383, 1.29514}};
miF@A
(* {{20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20.},
{20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1,
20.1, 20.1, 20.1, 20.1},
{20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2,
20.2, 20.2, 20.2, 20.2},
{20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3,
20.3, 20.3, 20.3}} *)
miF @ A == rPF @ A == tbF @ A
(* True *)
Using:
A = {{0.620161, 0.320312, 0.94842, 1.11844, 1.12045, 1.12539, 1.13177,
1.13142, 1.15048, 1.23244, 0.721388, 0.708943, 0.750067,
0.744916, 0.720972, 0.674833, 1.29773, 1.29514}, {0.620161,
0.320312, 0.94842, 1.11844, 1.12045, 1.12539, 1.13177, 1.13142,
1.15048, 0.721388, 0.750067, 0.744916, 0.720972, 0.674833,
1.29383, 1.29514}, {0.620161, 0.320312, 0.94842, 1.11844, 1.12045,
1.12539, 1.13177, 1.13142, 1.15048, 0.721388, 0.750067, 0.744916,
0.720972, 0.674833, 1.29383, 1.29514}, {0.620161, 0.320312,
0.94842, 1.11844, 1.12539, 1.13177, 1.13142, 1.15048, 0.721388,
0.750067, 0.744916, 0.720972, 0.674833, 1.29383, 1.29514}};
A function to replace list:
rep[a_, v_] := MapThread[Table[#2, {Length@#1}] &, {a, v}]
so
rep[A, 19.9 + Range[Length[A]]/10]
yields:
{{20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20., 20.,
20., 20., 20., 20., 20.}, {20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1,
20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1, 20.1}, {20.2, 20.2,
20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2, 20.2,
20.2, 20.2, 20.2}, {20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3,
20.3, 20.3, 20.3, 20.3, 20.3, 20.3, 20.3}}