MathGroup Archive 2012

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

Search the Archive

Re: please help using NDSolve and FindFit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126798] Re: please help using NDSolve and FindFit
  • From: Robert Miller <robertelmiller at gmail.com>
  • Date: Fri, 8 Jun 2012 03:35:39 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jqprpc$2dv$1@smc.vnet.net>

Try
fit = FindFit[data, model[p, q][f], {{p, 2}, {q, 4}}, f]
I get
{p -> 1.99877, q -> 3.99766}
along with a FindFit::sszero message

On Thursday, June 7, 2012 2:20:44 AM UTC-7, Lee wrote:
> As reading tutorials by Mathew Smith, I am trying to fit six (t,f) data points in range t=[0,5] using a conditional differential equation.
> 
> texp = {0.5, 1.1, 1.5, 2.1, 2.3, 3.1};
> fexp = {6.2, 8.1, 8.8, 8.3, 6.8, 2.9};
> data = Transpose[{texp, fexp}];
> model[p_?NumberQ, q_?NumberQ] := First[f /. NDSolve[{f'[t] == If[t < p, 10 - f[t], -f[t]], f[0] == q}, f, {t, 0, 5}]];
> fit = FindFit[data, model, {{p, 2}, {q, 4}}, f];
> 
> Mathematica gave the following error message:
> 
> FindFit::nrlnum: The function value {-6.2+model, -8.1+model, -8.8+model, -8.3+model, -6.8+model, -2.9+model} is not a list of real numbers with dimensions {6} at {p,q} = {2.,4.}.
> 
> The answer should have been around:
> 
> {p->1,9962, q->3.93581}
> 
> Does anyone know how to correct it?



  • Prev by Date: Re: Can Mathematica do regression, or similar?
  • Next by Date: Re: Can Mathematica do regression, or similar?
  • Previous by thread: Re: please help using NDSolve and FindFit
  • Next by thread: InverseZTransform numerical issue on some expression, version 8.0.4