RE: Sorting of Data Lists
- To: mathgroup@smc.vnet.net
- Subject: [mg11080] RE: [mg11011] Sorting of Data Lists
- From: Ersek_Ted%PAX1A@mr.nawcad.navy.mil
- Date: Wed, 18 Feb 1998 20:32:31 -0500
Dr. Christopher J. Freitas wrote:
----------
|I have two equal length vector sets of data. I wish to form a third
|vector whose elements are the minimum values from each component of
|the other two vectors; i.e., if a(i) < b(i), then c(i) = a(i), else
|c(i) = b(i). I have tried many different methods within Mathematica
|3.0 and have not been successful. I would appreciate any suggestions
|as to how to accomplish this task. |
See below.
In[1]:=
lst1={1,9,9,1,1,9,1};
lst2={2,3,2,3,2,3,2};
First I demonstrate what Transose does. In[2]:=
Transpose[{lst1,lst2}]
Out[2]=
{{1,2},{9,3},{9,2},{1,3},{1,2},{9,3},{1,2}}
The next line does the Transpose, and find the Minimum of each. In[3]:=
Map[Min,Transpose[{lst1,lst2}]]
Out[3]=
{1,3,2,1,1,3,1}
The line below is the same thinng using the short hand form. In[4]:=
Min/@Transpose[{lst1,lst2}]
Out[4]=
{1,3,2,1,1,3,1}
Ted Ersek