Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9039 > unrolled thread

Re: Map onto a column

Started bySseziwa Mukasa <mukasa@gmail.com>
First post2012-03-14 05:50 +0000
Last post2012-03-15 05:39 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Map onto a column Sseziwa Mukasa <mukasa@gmail.com> - 2012-03-14 05:50 +0000
    Re: Map onto a column Murta <rodrigomurtax@gmail.com> - 2012-03-15 05:39 +0000

#9039 — Re: Map onto a column

FromSseziwa Mukasa <mukasa@gmail.com>
Date2012-03-14 05:50 +0000
SubjectRe: Map onto a column
Message-ID<jjpbje$pbu$1@smc.vnet.net>
Transpose the matrix and MapAt the appropriate row then Transpose back:

Transpose[MapAt[f,Transpose[a],2]]

On Mar 13, 2012, at 4:02 AM, Sly Pandemia wrote:

> Is there a neat way to map a function onto a specific column in an
> array?
> 
> For example if I have
> 
> a = {{1,2,3},{4,5,6},{7,8,9}}
> 
> and I want to map f onto the second element in each row. I would
> normally use
> 
> b = Map[MapAt[f,#,2]&,a]
> 
> but this seems a bit awkward. I would expect to be able to use
> 
> b = MapAt[f,a,{All,2}]
> 
> but this appears to be illegal syntax.
> 
> Is there any way to do what I want with a single Map/MapAt function?
> 

[toc] | [next] | [standalone]


#9063

FromMurta <rodrigomurtax@gmail.com>
Date2012-03-15 05:39 +0000
Message-ID<jjrvah$9gs$1@smc.vnet.net>
In reply to#9039
I agree that some solution like that

   b = MapAt[f,a,{All,2}]

would be much more elegant. Maybe in Mathematica 9??

On Mar 14, 2:50 am, Sseziwa Mukasa <muk...@gmail.com> wrote:
> Transpose the matrix and MapAt the appropriate row then Transpose back:
>
> Transpose[MapAt[f,Transpose[a],2]]
>
> On Mar 13, 2012, at 4:02 AM, Sly Pandemia wrote:
>
>
>
>
>
>
>
> > Is there a neat way to map a function onto a specific column in an
> > array?
>
> > For example if I have
>
> > a = {{1,2,3},{4,5,6},{7,8,9}}
>
> > and I want to map f onto the second element in each row. I would
> > normally use
>
> > b = Map[MapAt[f,#,2]&,a]
>
> > but this seems a bit awkward. I would expect to be able to use
>
> > b = MapAt[f,a,{All,2}]
>
> > but this appears to be illegal syntax.
>
> > Is there any way to do what I want with a single Map/MapAt function?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web