MathGroup Archive 2003

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

Search the Archive

Re: curve fitting

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40820] Re: curve fitting
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Sat, 19 Apr 2003 23:02:47 -0400 (EDT)
  • References: <b7qono$3in$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

data={{0,3.786392146},{15,3.81806915},
      {30,3.880044496},{45,4.31622824},
      {60,4.523878538},{90,4.900042894},
      {120,5.175422767},{150,5.217956939},
      {180,5.262434094},{240,5.377787989},
      {300,5.36486329},{360,5.241879526},
      {420,5.234405371},{480,5.228778272},
      {540,5.219441168},{600,5.230700617},
      {660,5.305355251},{720,5.41936145},
      {780,5.50345499},{840,5.524101499},
      {900,5.546731139},{960,5.498010869},
      {1020,5.574792174},{1080,5.600864814},
      {1140,5.589530789},{1200,5.537377461},
      {1260,5.455131015},{1320,5.342847014},
      {1380,5.344745156},{1440,5.344745156}};

xmin=Min[data[[All,1]]];
xmax=Max[data[[All,1]]];

To get straight line interpolation set the InterpolationOrder to one.

f=Interpolation[data, InterpolationOrder->1];

To include the origin, manually set the PlotRange

Plot[f[x],{x,xmin,xmax},PlotStyle->RGBColor[0,0,1],
    Epilog->{AbsolutePointSize[5],RGBColor[1,0,0],
        Point/@data},ImageSize->400, PlotRange->{0,6}];

Note that it skipped over a few points (second and third) because the number of
PlotPoints was too small.  Increase the PlotPoints

Plot[f[x],{x,xmin,xmax},PlotStyle->RGBColor[0,0,1],
    Epilog->{AbsolutePointSize[5],RGBColor[1,0,0],
        Point/@data},ImageSize->400, PlotRange->{0,6},
    PlotPoints->50];

However, if all you want is a plot of straight line interpolation you can use
ListPlot

ListPlot[data, PlotJoined->True, 
    PlotStyle->RGBColor[0,0,1],PlotRange->{0,6},
    Epilog->{AbsolutePointSize[5],RGBColor[1,0,0],
        Point/@data},ImageSize->400];


Bob Hanlon

In article <b7qono$3in$1 at smc.vnet.net>, <cbhat at purdue.edu> wrote:

<< 
Subject:	curve fitting
From:		"C B" <cbhat at purdue.edu>
To: mathgroup at smc.vnet.net
Date:		Sat, 19 Apr 2003 06:01:28 +0000 (UTC)

please look at the following mathematica code which I actually got from some
of the good people on this newsgroup. The plot obtained in the last line of
the code, does not really look exactly line the plot given by Microsoft
EXcel. Can anyone explain what they are different ? Is it possible to obtain
an interpolation function for the plot the way it appears in Excel?

Are there any ways in Mathematica of getting information about the errors in
the curve fitting?



data = {{0, 3.786392146}, {15, 3.81806915}, {30, 3.880044496}, {45,
      4.31622824}, {60, 4.523878538}, {90, 4.900042894}, {120,
      5.175422767}, {150, 5.217956939}, {180, 5.262434094}, {240,
      5.377787989}, {300, 5.36486329}, {360, 5.241879526}, {420,
      5.234405371}, {480, 5.228778272}, {540, 5.219441168}, {600,
      5.230700617}, {660, 5.305355251}, {720, 5.41936145}, {780,
      5.50345499}, {840, 5.524101499}, {900, 5.546731139}, {960,
      5.498010869}, {1020, 5.574792174}, {1080, 5.600864814}, {1140,
      5.589530789}, {1200, 5.537377461}, {1260, 5.455131015}, {1320,
      5.342847014}, {1380, 5.344745156}, {1440, 5.344745156}}


<< NumericalMath`NIntegrateInterpolatingFunct`

f = Interpolation[data]

NIntegrateInterpolatingFunction[f[x], {x, 0, 1440}]

xmin = Min[data[[All, 1]]]
xmax = Max[data[[All, 1]]]


Plot[f[x], {x, xmin, xmax},
PlotStyle -> RGBColor[0, 0, 1],
Epilog -> {AbsolutePointSize[5],
RGBColor[1, 0, 0], Point /@ data},
ImageSize -> 400]



















 >><BR><BR>


  • Prev by Date: Re: Minimisation Problem
  • Next by Date: Re: Copying and Pasting Output that has StyleForm
  • Previous by thread: Re: curve fitting
  • Next by thread: Re: curve fitting