0
$\begingroup$

Suppose my data is

{{0., 0., 0.}, {-0.0203939, 0.0196729, 5.90962*10^-21}, {-0.0415497, 
  0.0386641, -2.9556*10^-19}, {-0.063427, 
  0.056934, -7.2506*10^-19}, {-0.0859824, 
  0.0744451, -6.65512*10^-19}, {-0.109169, 
  0.0911626, -3.87827*10^-19}, {-0.13294, 
  0.107054, -5.32617*10^-19}, {-0.157241, 0.12209, 
  3.83763*10^-19}, {-0.18202, 0.136244, 1.17879*10^-19}, {-0.207219, 
  0.149492, 9.4574*10^-19}, {-0.232781, 0.161815, 3.64846*10^-19}}

How can I take first and second element in every row, my expect data is {{0,0},{-0.0203939, 0.0196729}...? I have try [[]] but fails.

Any comments very be much appreciate!

$\endgroup$
2
  • $\begingroup$ 'Take[Data, 1, 2]' can get {{0,0}}, it seems close to the answer? $\endgroup$
    – lumw
    Nov 20, 2021 at 13:56
  • 1
    $\begingroup$ try Most/@data $\endgroup$
    – Bob Hanlon
    Nov 20, 2021 at 14:51

1 Answer 1

2
$\begingroup$

Take[data, All, 2] works.

I have find the answer! Take is very useful!

$\endgroup$
2
  • $\begingroup$ by the way, can I use [[]] do same thing? $\endgroup$
    – lumw
    Nov 20, 2021 at 13:59
  • 3
    $\begingroup$ data[[All, {1, 2}]] $\endgroup$
    – cvgmt
    Nov 20, 2021 at 14:08

Your Answer

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

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