MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Manipulating vectors with Position

  • To: mathgroup at
  • Subject: [mg117339] Manipulating vectors with Position
  • From: Lengyel Tamas <lt648 at>
  • Date: Tue, 15 Mar 2011 06:07:14 -0500 (EST)

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

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.


  • Prev by Date: Re: How to interactively re-scale graphics with mouse?
  • Next by Date: Expressions as images
  • Previous by thread: New Mathematica Q&A on the Wolfram blog
  • Next by thread: Re: Manipulating vectors with Position