Re: Comparing Corresponding Columns of Two Matrices

• To: mathgroup at smc.vnet.net
• Subject: [mg97534] Re: Comparing Corresponding Columns of Two Matrices
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Sat, 14 Mar 2009 18:16:08 -0500 (EST)
• References: <gpg1gu\$cl7\$1@smc.vnet.net>

```Hi,

\[ScriptCapitalX] = Table[RandomInteger[{0, 255}], {10}, {4}];
\[ScriptCapitalY] = Table[RandomInteger[{0, 255}], {10}, {4}];

MapThread[#1 > #2 &, {\[ScriptCapitalX], \[ScriptCapitalY]}, 2]

??

Regards
Jens

Gregory Lypny wrote:
> 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: inverse of calculation
• Next by Date: Re: Hash function
• Previous by thread: Re: Comparing Corresponding Columns of Two Matrices
• Next by thread: Re: Comparing Corresponding Columns of Two Matrices