MathGroup Archive 1997

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

Search the Archive

Re: Fit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg7044] Re: [mg7011] Fit
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Sat, 3 May 1997 22:04:39 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

WANNKE Michael <wannkem8 at cti.ecp.fr>
[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]:=...)?

Michael,

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];

Check

Plot[f[z],{z,0,4},
	Epilog->{PointSize[.02],Point/@data},PlotRange->All]
	
Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk




  • 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