MathGroup Archive 1997

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

Search the Archive

Re: Fit

  • To: mathgroup at
  • Subject: [mg7044] Re: [mg7011] Fit
  • From: Allan Hayes <hay at>
  • Date: Sat, 3 May 1997 22:04:39 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

WANNKE Michael <wannkem8 at>
[mg7011] Fit

>if I use the following command line:
>fitted = Fit[database,{1,x,x^2},x]
>Mathematica returns a fixed expression with x as variable. The  
>problem is that now x is the only variable which can be used:
>Plot[fitted,{x,0,1000}] returns the right graph
>Plot[fitted, {z,0,1000}] returns an error!

>How can I fit my database in order to get a function (style >f[x]:=...)?


data = Table[{x,Cos[x]+Random[]/3},{x,0,5}];
fx = Fit[data, {1,x,x^2},x];      (*a polynomial in x*)
f[x_] = fx;   		(* = not := , so that fx is evaluated*)

Or, in one step,

f[x_] = Fit[data, {1,x,x^2},x];


Allan Hayes
hay at

  • Prev by Date: How is the performance of Position[] ..
  • Next by Date: Re: Numerical Solving of a system of equations
  • Previous by thread: Re: Fit
  • Next by thread: Re: Fit