Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10373
| From | Lee <lee787@comcast.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | please help using NDSolve and FindFit |
| Date | 2012-06-07 09:20 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jqprpc$2dv$1@smc.vnet.net> (permalink) |
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 — Next 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