 
 
 
 
 
 
Re: Re: naive question
- To: mathgroup at smc.vnet.net
- Subject: [mg92881] Re: [mg92844] Re: [mg92781] naive question
- From: Francisco Gutierrez <fgutiers2002 at yahoo.com>
- Date: Thu, 16 Oct 2008 05:07:16 -0400 (EDT)
- Reply-to: fgutiers2002 at yahoo.com
Dear Friends:
I also want to thank all the other responses that came after Bob' and Valerie's --which by the way reveal the very big flexibility of Mathematica.  Performing an imaginary "union" operation, I counted at least five distinct, powerful solutions.
Best,
Francisco
--- On Tue, 10/14/08, Francisco Gutierrez <fgutiers2002 at yahoo.com> wrote:
From: Francisco Gutierrez <fgutiers2002 at yahoo.com>
Subject: [mg92881] [mg92844] Re: [mg92781] naive question
To: mathgroup at smc.vnet.net
Date: Tuesday, October 14, 2008, 4:01 AM
Many thanks to Bob and Valerie for their fast and ultraeffective responses.
Best,
Francisco
--- On Mon, 10/13/08, Bob Hanlon <hanlonr at cox.net> wrote:
From: Bob Hanlon <hanlonr at cox.net>
Subject: [mg92881] [mg92844] Re: [mg92781] naive question
To: fgutiers2002 at yahoo.com, mathgroup at smc.vnet.net
Date: Monday, October 13, 2008, 6:26 AM
expr = Fit[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, {1, x1, x2}, {x1, x2}];
Flatten[CoefficientList[expr, {x2, x1}]] // Most
{1.55556,0.555556,0.444444}
Most is used to drop the coefficient (0) of the (x1*x2) term
Cases[expr, _?NumericQ, Infinity]
{1.55556,0.555556,0.444444}
Or using FindFit rather than Fit
{a, b, c} /.
 FindFit[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}},
  a + b*x1 + c*x2, {a, b, c}, {x1, x2}]
{1.55556,0.555556,0.444444}
Bob Hanlon
---- Francisco Gutierrez <fgutiers2002 at yahoo.com> wrote:
=============
Dear Friends:
I am using Fit within a function, and I want it to produce only a list of
 coefficients, without the variables.
For example, if I plug into fit the following:
Fit[{{1,2,3},{4,5,6},{7,8,9}},{1,x1,x2},{x1,x2}],
Mathematica produces:
1.55556+0.555556 x1+0.444444 x2
I want to get only the following list:
{1.55556,0.555556,0.444444}
It seem awfully simple, but I haven't managed.
How can I do it?
Thanks
Francisco
--
Bob Hanlon

