I have a sequence of matrices/lists
testlist = {{85, 75, 1}, {84, 74, 2}, {83, 73, 3}, {82, 72, 4},
{81, 71, 5}, {80, 70, 6}, {79, 69, 7}, {78, 68, 8},
{77, 67, 9}, {76, 66, 10}, {75, 65, 11}};
Table[list[H1R] = DeleteCases[testlist, a_ /; a[[1]] <= H1R || a[[2]] >= H1R],
{H1R, 80, 78, -1}
]
namely
list[80] = {{85, 75, 1}, {84, 74, 2}, {83, 73, 3}, {82, 72, 4}, {81, 71, 5}}
list[79] = {{85, 75, 1}, {84, 74, 2}, {83, 73, 3}, {82, 72, 4}, {81, 71, 5},
{80, 70, 6}}
list[78] = {{85, 75, 1}, {84, 74, 2}, {83, 73, 3}, {82, 72, 4}, {81, 71, 5},
{80, 70, 6}, {79, 69, 7}}
Now I'd like to be able to, in one shot, using Table
or something, in all lists replace all records/rows where say the second element is between 74.5
and 72.3
with a replacement row say {-10,5,0.3}
So at the end of my one shot operation or Table
, I'll have:
list[80] = {{85, 75, 1}, {-10,5,0.3}, {-10,5,0.3}, {82, 72, 4},
{81, 71, 5}}
list[79] = {{85, 75, 1}, {-10,5,0.3}, {-10,5,0.3}, {82, 72, 4},
{81, 71, 5}, {80, 70, 6}}
list[78] = {{85, 75, 1}, {-10,5,0.3}, {-10,5,0.3}, {82, 72, 4},
{81, 71, 5}, {80, 70, 6}, {79, 69, 7}}
These lists that I have generated for my example are very similar to each other but my actual lists are quite different and are non-integer and basically I would like to be able to scan all of the lists in one shot and replace certain rows by other rows provided the elements of the rows or functions of elements of the said row fall in some interval.
Second Update:
Mimicking what you guys have done, I did this because I didn't want to write {,.._} because I have 15 columns now and I might have more later:
Table[list[i]=list[i] /. a_ :> {-10, 5, 0.3} /;Dimensions[a] == {3} && 72.3 < a[[2]] < 74.5, {i, 78, 80}]
This code works. woohoo!!