Suppose I have the following matrix (i,j):
mat = {{19.8134, 54.7015, 64.1866, 75.5597, 88.8358, 83.7313, 93.0299,
88.2537, 101.03, 108.873, 91.8731, 88.097, 82.0075, 88.7164,
83.5672, 69.9254, 56.0149, 31.4328, 19.4179, 6.40299, 1.48507,
0.410448, 0.171642, 0, 0}, {24.2741, 52.6815, 64.4667, 74.8593,
87.6222, 87.1926, 96.3407, 90.0667, 98.2519, 103.496, 89.7926,
85.1259, 83.4889, 88.7111, 86.1852, 75.4296, 53.7778, 34.0667,
19.6889, 7.40741, 2.16296, 0.348148, 0.00740741, 0, 0}, {18.4632,
50.6544, 60.5735, 72.5441, 86.0956, 84.9485, 91.1103, 84.8603,
94.3897, 100.463, 83.6324, 82.9412, 77.4853, 79.6324, 77.9485,
61.9118, 48.7574, 27.8309, 13.8824, 5.96324, 1.60294, 0.529412,
0.0294118, 0, 0}, {19.1212, 59.0985, 71.6818, 86.8182, 96.553,
91.5455, 100.402, 92.6515, 111.068, 111.909, 95.7803, 94.3864,
92.75, 90.8182, 95.3561, 86.197, 73.6136, 51.5682, 40.6742, 15.1515,
3.30303, 0.848485, 0.0757576, 0.030303, 0.030303}, {19.6083,
55.5917, 66.5583, 75.575, 87.6, 89.1417, 96.1083, 92.6917, 108.375,
117.3, 96.7333, 91.8167, 86.6583, 91.7333, 93.45, 79.5333, 60.275,
36.95, 24.3583, 9.60833, 1.76667, 0.416667, 0.00833333, 0.0333333,
0}}
The following is my criteria vector that each element corresponding to each row of the above matrix:
check = {7.94021, 7.95033, 7.44576, 8.83645, 8.38877}
Here is my criteria. If the element in mat[[i,All]]
is less than the corresponding element in check[[i]]
vector, I want to replace with the following vector
replacevec = {79.4021, 79.5033, 74.4576, 88.3645, 83.8877}
where each element (replacevec[[i]])
correspond to each row in mat
.
Could you give me suggestions?
Thank you for help.
mat[[i,All]]
is a vector of length 25. What is being compared? Is it a single comparison for each row or is each element in row being compared with check element for that row? $\endgroup$mat[[i,All]]
ormat[[All,i]]
? mat[[i,All]] has different length compared withcheck
orreplacevec
. $\endgroup$mat
in row being compared withcheck
element. For example, any numbers in first row ofmat
that is less than the first value ofcheck
vector (check[[1]]) will be replaced with the first element ofreplacevec
(replacevec[[1]]) and so on... $\endgroup$