3
$\begingroup$

I have RLC circuit. I would like to find R and L by using FindFit, but L is in initial condition and I have problem with it. Could you help me ?

c = 116*10^(-6); U = 16000. ; 

data = 
{
   {0, 0}, {0.25*10^(-6), 132000}, {0.5*10^(-6), 330000}, {1*10^(-6), 462000}, 
   {2*10^(-6), 600000}, {3*10^(-6), 462000}, {4*10^(-6), 330000}, {5*10^(-6), 66000}, 
   {6*10^(-6), -198000}, {7*10^(-6), -264000}, {8*10^(-6), -198000}, {9*10^(-6), -132000}
};

lp = ListPlot[data, PlotRange -> All]

fit = 
  FindFit[data,
    First[i /. 
      NDSolve[{i''[t] + R/L * i'[t] + 1/(c L)*i[t] == 0, i[0] == 0, i'[0] == U/L}, 
        i, {t, 0, 9*10^(-6)}]],
    {{R, 10*10^(-3)}, {L, 20*10^(-9)}}, 
    i, 
    PrecisionGoal -> 4, 
    AccuracyGoal -> 4]
$\endgroup$
5
$\begingroup$

Your set up:

c = 116*10^(-6); U = 16000;

data = {{0, 0}, {0.25*10^(-6), 132000}, {0.5*10^(-6), 
    330000}, {1*10^(-6), 462000}, {2*10^(-6), 600000}, {3*10^(-6), 
    462000}, {4*10^(-6), 330000}, {5*10^(-6), 
    66000}, {6*10^(-6), -198000}, {7*10^(-6), -264000}, {8*10^(-6), \
-198000}, {9*10^(-6), -132000}};

Use analytic not numerical form DSolve:

model = (i /. 
     DSolve[{i''[t] + R/L*i'[t] + 1/(c L)*i[t] == 0, i[0] == 0, 
       i'[0] == U/L}, i, {t, 0, 9*10^(-6)}])[[1, 2]];
model // TraditionalForm

enter image description here

Find a fit:

fit = NonlinearModelFit[data, model, {{R, 10*10^(-3)}, {L, 20*10^(-9)}}, t];
fit["BestFitParameters"]

{R -> 0.0109553, L -> 2.15996*10^-8}

Show[ListPlot[data], 
 Plot[fit[x], {x, 0, 9 10^-6}, PlotStyle -> Directive[Red, Thick]], 
 Frame -> True, PlotRange -> All]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you very much for help. What if we treat equation as without analytical solution ? $\endgroup$ – Krzysiek Aug 25 '14 at 10:33
  • $\begingroup$ @Krzysiek In such case I would try using ParametricNDSolve - look through the examples HERE to grasp the scope. $\endgroup$ – Vitaliy Kaurov Aug 25 '14 at 18:51

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.