1
$\begingroup$

I am trying to fit my data to an inverse function from solving a DGL:

extf = 15
data = Import["http://pastebin.com/raw.php?i=mTQUNBua", "Table"];
ListPlot[data]
sol = DSolve[{a*L'[t] == b*L[t]^(-3/2) - c, L[0] == L0}, L, t]
Block[{b = 40000, c = 1.4 + extf, L0 = 10}, 
       fit=FindFit[data, L[t] /. sol, {a}, t]]
Plot[fit,{t,0,100}]

Obviously this takes a huge amount of time. But after a while weird error messages start to show up. Is this in principle the right approach?

$\endgroup$
  • $\begingroup$ What kind of error messages? $\endgroup$ – dr.blochwave Nov 3 '14 at 19:23
  • $\begingroup$ FindFit::nrlnum: "The function value {-47.5437+0.\ I,-32.8991+0.\ I,-22.3144+0.\ I,-13.9991+0.\ I,-7.09261+0.\ I,-1.16642+0.\ I,4.03917 +0.\ I,8.67588 +0.\ I,<<36>>,66.0943 +0.\ I,66.5301 +0.\ I,66.9401 +0.\ I,67.3269 +0.\ I,67.6895 +0.\ I,68.0316 +0.\ I,<<9950>>} is not a list of real numbers with dimensions {10000} at {a} = {1.}. " $\endgroup$ – MaxJ Nov 3 '14 at 19:24
  • $\begingroup$ And in the end the plot is just empty $\endgroup$ – MaxJ Nov 3 '14 at 19:24
2
$\begingroup$
data = Import["http://pastebin.com/raw.php?i=mTQUNBua", "Table"];
b = 40000; c = 1.4 + 15; L0 = 10; 
fun = L /. ParametricNDSolve[{a*L'[t] == b*L[t]^(-3/2) - c, L[0] == L0}, L, {t, .2, 2000}, {a}]
fit = FindFit[data[[1 ;; -1;; 10]], {fun[a][t], 9 < a < 15}, {{a, 10}}, t]

(* {a -> 14.026} *)

Show[Plot[fun[a /. fit[[1]]][t], {t, .2, 2000}, PlotRange -> All, PlotStyle -> {Thick, Red}],
    ListPlot[data[[1 ;; -1 ;; 100]]]]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.