MathGroup Archive 2005

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

Search the Archive

Re: MapThread

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57054] Re: MapThread
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Thu, 12 May 2005 22:44:53 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 5/12/05 at 2:32 AM, swatshah at gmail.com (Swati Shah) wrote:

>I have been working on the following problem:

>states = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}

>stim = {33, 44, 55, 66, 77}

>The locations of state 3,5,7,9,11 to be equal 33,44,55,66,77

>MapThread[{#1 = #2} &, {Take [states, {3, 12, 2}], stim}]

>I tried to the above but it gives me errors: Set::setraw: Cannot
>assign to raw object 3

>However these work individually: 
>MapThread[#1 &, {Take [states, {3, 12, 2}], stim}] 

This is exactly equivalent to Take[states, {3, 12, 2}]

>MapThread[ #2 &, {Take [states, {3, 12, 2}], stim}]

And this is exactly equivalent to stim

That is MapThread isn't needed in either of these.

Quite frankly, it is not at all obvious as to what it is you want.

If what you are trying to create is a pairing of selected values from state with stim, then noting the values from state are odd integers starting from 3

MapIndexed[Flatten@{#1, 2 #2 + 1}&, stim]

will do the trick.

This can be made a little more general using

Transpose@{stim, Take[states, {3, 12, 2}]}

Which eliminates the assumption about the desired state values being odd integers
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Reading in a file
  • Next by Date: Re: Numerical Eigenvalues for a 11x11 matrix
  • Previous by thread: Re: MapThread
  • Next by thread: dsolve?