[Date Index]
[Thread Index]
[Author Index]
Re: take square of the second and third column of a table
*To*: mathgroup at smc.vnet.net
*Subject*: [mg124186] Re: take square of the second and third column of a table
*From*: Murray Eisenberg <murray at math.umass.edu>
*Date*: Thu, 12 Jan 2012 04:18:18 -0500 (EST)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*References*: <201201112220.RAA22144@smc.vnet.net>
*Reply-to*: murray at math.umass.edu
You can't really operate upon a "table" in Mathematica, as there is no
such object. You want instead to operate upon elements at prescribed
positions in sublists of a list. (You may _display_ such a list of lists
in Table form.)
Here's one quick way, by example:
tbl = Partition[RandomInteger[{1, 10}, 12], 3];
tbl /. {x_, y_, z_}:> {x, y^2, z^2}
On 1/11/12 5:20 PM, hanciong awesome wrote:
> Hello, suppose I have a very long table like this:
>
> 1 2 3
> 4 5 6
> 7 8 9
> .......
> 2 3 4
>
> how can I take square of the 2nd and 3rd column? I always do it by
> making a new table. so let's say the above table is A and it has 100
> lines, then I make the new table as the following:
>
> B=Table[{A[[n]][[1]],A[[n]][[2]]^2,A[[n]][[3]]^2},{n,1,100}]
>
> But if the length of the table is unknown, this way is impractical.
> Could anyone suggests better way? thank you
>
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Prev by Date:
**Re: take square of the second and third column of a table**
Next by Date:
**Re: take square of the second and third column of a table**
Previous by thread:
**Re: take square of the second and third column of a table**
Next by thread:
**Re: take square of the second and third column of a table**
| |