MathGroup Archive 2006

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

Search the Archive

Re: Creating a new table using values from a column in another table,

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66403] Re: [mg66346] Creating a new table using values from a column in another table,
  • From: János <janos.lobb at yale.edu>
  • Date: Thu, 11 May 2006 02:16:28 -0400 (EDT)
  • References: <200605101034.GAA21842@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On May 10, 2006, at 6:34 AM, Wonko the Sane wrote:

> Hi all,
>
> I have a question that I have not been able to work out myself, and so
> put it to the group to help. I have a set of data points in a table (2
> columns {{x1,y1},{x2,y2},....,{xn,yn}}) I have performed a fit to the
> data and have a function f[x] which I would now like to evaluate at  
> each
> data point (column 1 of the first table) to get a new table
> {{x1,f[x1]},{x2,f[x2]},....,{xn,f[xn]}}. Is there a way to do this? I
> hope my request is clear
>
> Best Regards
> Michael

Here is a newbie approach:

In[1]:=
lst = Table[{ToExpression[
      StringJoin["x",
       ToString[i]]],
     ToExpression[StringJoin[
       "y", ToString[i]]]},
    {i, 5}]
Out[1]=
{{x1, y1}, {x2, y2},
   {x3, y3}, {x4, y4},
   {x5, y5}}

In[3]:=
({#1[[1]], f[#1[[1]]]} & ) /@
   lst
Out[3]=
{{x1, f[x1]}, {x2, f[x2]},
   {x3, f[x3]}, {x4, f[x4]},
   {x5, f[x5]}}

János


---------------------------------------------------------
What is the difference between OS X and Vista ?

Microsoft employees are exited about OS X.

http://daringfireball.net/2006/04/windows_the_new_classic




  • Prev by Date: Re: Rules
  • Next by Date: RE: Creating a new table using values from a column in another table,
  • Previous by thread: Re: Creating a new table using values from a column in another table,
  • Next by thread: Re: Creating a new table using values from a column in another table,