Comparing Corresponding Columns of Two Matrices

• To: mathgroup at smc.vnet.net
• Subject: [mg97496] Comparing Corresponding Columns of Two Matrices
• From: Gregory Lypny <gregory.lypny at videotron.ca>
• Date: Sat, 14 Mar 2009 05:39:39 -0500 (EST)

```Hello everyone,

I'm trying to develop a modest skill in mapping functions and I've
been working on this problem.

Suppose I have two 100 x 4 matrices, X and Y, and I want to see
whether each value in a column of X is bigger than each value in the
corresponding column of Y.  In other words, compare column 1 of X with
column 1 of Y, column 2 of X with column 2 of Y, and so on.

It's easy to generate a 100 x 4 table of Booleans using Table as

Table[Boole[X[[i ,  j]] > Y[[i, j]]], {i, 100}, {j, 4}]

But what about without Table?  I am able to do it for the comparison
of any one column as

Boole[#[[1]] > #[[2]]] & /@ Transpose[{X[[All, ]], Y[[All, 1]]}]

but I'm not sure how to extend this to other columns.  Any tip would
be much appreciated.

Regards,

Gregory

```

• Prev by Date: Re: Mathematica 7.0.1.0 and some General Comments
• Next by Date: Re: Request for help - Minimize
• Previous by thread: Re: Hash function
• Next by thread: Re: Comparing Corresponding Columns of Two Matrices