Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Manipulating vectors with Position
Replies: 7   Last Post: Mar 16, 2011 6:53 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Lengyel Tamas

Posts: 10
Registered: 2/23/11
Manipulating vectors with Position
Posted: Mar 15, 2011 6:24 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear Mathworld Users,
I am tackling a rather straightforward problem. Here it is.

1) I have generated an array of values (Array1)
2) I have generated an array of vectors in Array2, whose Length varies,
and in each subvector the numbers contain the Position (index) of those
elements that I need from Array1. So far so good.

3) What I need is to create a code that picks out those elements from
Array 1 and ads them together if Array2's subvectors have more than 1
element.

Here's an example to make it clear:

Array1 = {a,b,c,d,e,f}; (*a;;f are numbers*)
Array2 = {{1}, {2,4,5}, {3,6}};

My outpout should be: {{a}, {a+d+e}, {c+f}}

I think it is simple, but I can't seem to do it.

Any ideas?

Thank you.

Tamás




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.