MathGroup Archive 1999

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

Search the Archive

Fitting a piecewise continuous Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16646] Fitting a piecewise continuous Function
  • From: Jason Gill <jgill at vbimail.champlain.edu>
  • Date: Fri, 19 Mar 1999 12:54:00 -0500
  • Organization: IBM Microelectronics
  • Sender: owner-wri-mathgroup at wolfram.com

Folks,
    I am trying to fit a piecewise continuous function to some data.
Here is a simple example, I hope someone can help me out with.
Here I have a function
In[69]:=
testF[t_]:=r0/;t<ti;
testF[t_]:=r0+5*(t-ti)/;t>=ti;
If I define values for r0 & ti,
r0=5;
ti=11;
This function is continuous and may be plotted.
In[75]:=
Plot[testF[t],{t,0,15}]
Graphic Not included.

The question is, how can I perform a NonlinearFit using the above
function to some data.
Suppose I have the sample data below, how do I Fit the function to the
data, with fit parameters.  r0, and ti.
Sample data:
data1=Table[5,{i,1,10}];
data2=Table[5*i,{i,1,10}];
data=Transpose[{Range[Length[Join[data1,data2]]],Join[data1,data2]}];

I tried (after clearing the values for r0 & t) to perform a NonlinearFit

In[7]:=
NonlinearFit[data,testF[t],{t},{{r0,5},{ti,10}}]
Out:
    The model is not numerical at {r0->5,ti->10,t->1}.

but this does not work.  What technique do I need to use to get
Mathematica to perform the fit as I have described? What am I missing?
Any suggestions would be welcome.
Thanks,
Jason



  • Prev by Date: Re: An open letter
  • Next by Date: Re: ... but true
  • Previous by thread: Re: unbelievable ...(continued)
  • Next by thread: RE: Fitting a piecewise continuous Function