MathGroup Archive 1998

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

Search the Archive

RE: Sorting of Data Lists




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




  • Prev by Date: RE: Drawing intrinsic coordina
  • Next by Date: Re: Sorting of Data Lists
  • Prev by thread: Re: Sorting of Data Lists
  • Next by thread: Re: Sorting of Data Lists