Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I have a long list of coordinates defined in some 8D space. I need to extract the first three coordinates only. How ?

For example :

coords = {{0.1, 0.4, -0.2, 1.2, 3.2, 0.5, 0.8, 2.2}, ...};

I need to define the list of all first three components :

reducedCoords := {{0.1, 0.4, -0.2}, ...}

Please, notice that I'm working with Mathematica 7.

share|improve this question

marked as duplicate by Sjoerd C. de Vries, Mr.Wizard Mar 29 '13 at 19:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Take[#, 3] & /@ coords takes first three elements from each sublist. –  BoLe Mar 29 '13 at 15:37
add comment

1 Answer 1

up vote 4 down vote accepted

This is core functionality:

coords = Table[Range[5], {3}]

{{1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}}

coords[[All, 1 ;; 3]]

{{1, 2, 3}, {1, 2, 3}, {1, 2, 3}}

share|improve this answer
    
beat me by 2 seconds! –  s0rce Mar 29 '13 at 15:35
1  
Ok, it's working. Thanks a lot ! –  Cham Mar 29 '13 at 15:39
add comment

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