Suppose I have the following list:
and I have a given value of maxDh
(let's say 0.5) . How can I replace only the values in the second position with a given operation (e.g. maxDh*5
) only when the values of the first position are greater than 74
and maxDh
is lower than 1.2
(as in this case)?. For example given that in this example maxDh=0.5
, then I would get: {{40,0.0712996},{40.,0.0712996},{40.,0.0712996}......{74.0202,2.5},{74.0404,2.5},{74.2023,2.5}....etc.
Thank you very much in advanced,
list /. {a_?(# > 74 &), b_?(# < 1.2 &)} :> {a, 2.5}
? Can you explain whatdhMax
is here though? Is it the second element of each pair? $\endgroup$ListPlot[%]
before & after $\endgroup$maxDh
(which I corrected in the EDIT) is the number that tells me if the condition should be done or not. Anytime thatmaxDh
is lower than 1.2, then I need to replace all of the values in the second position with the given operation only when the values of the first postion are greater than 74. So, In the case of your code perhaps it would be something like:list /. {a_?(# > 74 &), b_?(maxDh < 1.2 &)} :> {a, 2.5}
? but it does not seem to work like this $\endgroup$maxDh
has nothing to do with the list. It's just a number I use in my code that tells me if I should apply the requested code or not. If it is below 1.2 then I applied the requested code with the condition, if It is greater than 1.2, then simply the list remains the same and nothing happens. $\endgroup$