Re: Creating a new table using values from a column in another table,
- To: mathgroup at smc.vnet.net
- Subject: [mg66389] Re: Creating a new table using values from a column in another table,
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Thu, 11 May 2006 02:15:41 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 5/10/06 at 6:34 AM, noone at nowhere.com (Wonko the Sane) wrote: >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? Yes, here are a few ways to do what you want In[1]:= data={{x1,y1},{x2,y2},{xn,yn}}; {First@#,f@First@#}&/@data Out[2]= {{x1, f[x1]}, {x2, f[x2]}, {xn, f[xn]}} In[4]:= Transpose@{data[[All,1]],f/@data[[All,1]]} Out[4]= {{x1, f[x1]}, {x2, f[x2]}, {xn, f[xn]}} In[5]:= {#,f@#}&/@data[[All,1]] Out[5]= {{x1, f[x1]}, {x2, f[x2]}, {xn, f[xn]}} -- To reply via email subtract one hundred and four