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


Groups > comp.soft-sys.math.mathematica > #7762

Re: take square of the second and third column of a table

From "Nasser M. Abbasi" <nma@12000.org>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: take square of the second and third column of a table
Date 2012-01-12 09:20 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jem8ki$1ak$1@smc.vnet.net> (permalink)
References <jel20o$lkl$1@smc.vnet.net>

Show all headers | View raw


On 1/11/2012 4:21 PM, hanciong awesome wrote:

>
> how can I take square of the 2nd and 3rd column?

I forgot to mention the simplest method, which is to square the slice
of the matrix directly.


tbl = {{1, 2, 3},{4, 5, 6},{7, 8, 9},{2, 3, 4}}

for second col:

tbl[[All, 2]]^2
-->{4, 25, 64, 9}

to do both cols at same time:

tbl[[All, {2, 3}]]^2
---> {{4, 9}, {25, 36}, {64, 81}, {9, 16}}

I like to Map allot, and so sometimes I overlook that it might not
be needed.

--Nasser




Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

take square of the second and third column of a table hanciong awesome <hanciong@gmail.com> - 2012-01-11 22:21 +0000
  Re: take square of the second and third column of a table "Nasser M. Abbasi" <nma@12000.org> - 2012-01-12 09:20 +0000
  Re: take square of the second and third column of a table "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2012-01-12 09:22 +0000
  Re: take square of the second and third column of a table "Nasser M. Abbasi" <nma@12000.org> - 2012-01-12 09:23 +0000
  Re: take square of the second and third column of a table Helen Read <readhpr@gmail.com> - 2012-01-12 09:20 +0000

csiph-web