I have a list that contains a set of coordinates in the form {{x1,y1}, {x2,y2}, ...}. I want to edit the list in manner that it takes the log() of all the y coordinates only. Essentially, I want redefine the list such that it now contains {{x1,log(y1)}, {x2,log(y2)}, ...}.

  • $\begingroup$ list[[All,2]]=Log[list[[All,2]]]? $\endgroup$ Oct 18 '20 at 13:11
  • $\begingroup$ {#1, Log[#2]} & @@@ {{x1, y1}, {x2, y2}, {x3, y3}} $\endgroup$
    – cvgmt
    Oct 18 '20 at 13:20
  • 1
    $\begingroup$ {#[[1]], Log@#[[2]]} & /@ {{x1, y1}, {x2, y2}, {x3, y3}} $\endgroup$
    – wuyudi
    Oct 18 '20 at 14:50
  • $\begingroup$ thanks for the help. cvgmt and wuyudi's answers worked perfectly. Henrik, your suggestion creates something like for every x coordinate, it logs all the other y coordinates. while this wasn't the solution I was looking for, it helped understand how to manipulate lists better so thanks. $\endgroup$
    – Anon77
    Oct 20 '20 at 9:21
{{x1, y1}, {x2, y2}, {x3, y3}} /. {x_, y_} :> {x, Log[y]}


{#1, Log[#2]} & @@@ {{x1, y1}, {x2, y2}, {x3, y3}}

Or the method which provided by @wuyudi


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.