7
$\begingroup$

I have three lists:

x = {x1, x2, ...},
y = {y1, y2, ...},
yErr = {y1Err, y2Err, ...}

that I want to join into the following format:

{{{x1, Around[y1, y1Err]}, {x2, Around[y2, y2Err]}, ...}}

How can I do this automatically?

$\endgroup$

2 Answers 2

9
$\begingroup$

Perhaps

MapThread[{#1,Around[#2,#3]}&,{x,y,yErr}]

is what you are looking for.

$\endgroup$
1
  • 1
    $\begingroup$ fabulous! just a typo correction: MapThread $\endgroup$ Apr 20, 2021 at 11:39
2
$\begingroup$

You can also use

{#, Around @ ##2} & @@@ Transpose[{x, y, yErr}]

or

Transpose[{x, Around @@@ Transpose[{y, yErr}]}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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