       • To: mathgroup at smc.vnet.net
• From: Lee <lee787 at comcast.net>
• Date: Thu, 7 Jun 2012 05:18:38 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```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 == 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: Converting from string to real
• Next by Date: Re: Converting from string to real
• Previous by thread: Re: Can Mathematica do regression, or similar?