MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re:Matrix manipulation

  • To: mathgroup at
  • Subject: [mg17038] Re:[mg16956] Matrix manipulation
  • From: "Tomas Garza" <tgarza at>
  • Date: Wed, 14 Apr 1999 02:11:53 -0400
  • Sender: owner-wri-mathgroup at

Martin [maa.150 at] wrote:

> question :   I have 2 matrices with 2 coulomns each.
> The first have 57 rows and the other 200 rows.
> The first coulomn in each matrix contains ID numbers and I
> would like to compare the two matrices and make a new matrix
> containing the ID number and the numbers in the second row ,  so
> the new matrix will be with 3 coulomns and 57 rows.
> how to do that ?

Hello, Martin:

A straightforward approach would be as follows: if a1 and a2 are your two
matrices, then


I.e., take all pairs where the first component is the same and put the two
second components together, and then delete those which didn't find a match.
However, for matrices of 57 and 200 rows, respectively, and depending on the
degree of coincidence of ID numbers (i.e., first component) the amount of
computing time could be inordinately large (as much as 30 seconds in a fast
machine). Still, if you are not in a hurry then the above method works fine.
But if the number of columns in your matrices increase, the time consumed
grows enormously and an alternative approach would be advisable.

Good luck,

Tomas Garza
Mexico City

  • Prev by Date: Re: Numerical calculation of derivative functions
  • Next by Date: Re(2): Re: Eigenvalue Problem
  • Previous by thread: Re: Matrix manipulation
  • Next by thread: Matrix manipulation