Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10393
| From | Robert Miller <robertelmiller@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: please help using NDSolve and FindFit |
| Date | 2012-06-08 07:36 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jqsa2l$de0$1@smc.vnet.net> (permalink) |
| 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?
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
please help using NDSolve and FindFit Lee <lee787@comcast.net> - 2012-06-07 09:20 +0000 Re: please help using NDSolve and FindFit Robert Miller <robertelmiller@gmail.com> - 2012-06-08 07:36 +0000
csiph-web