exponential fit not working

4 visualizaciones (últimos 30 días)
edo mor
edo mor el 1 de Jun. de 2018
Comentada: Walter Roberson el 2 de Jun. de 2018
i am trying to fit V*(1-exp(-x*(R/L))) to the voltage(over time) of a RL circuit using the cftool custom equation
this is my data
0.140530000000000
0.462380000000000
0.672240000000000
0.807240000000000
0.893120000000000
0.947740000000000
0.982350000000000
1.00491000000000
1.02096000000000
1.02863000000000
1.03526000000000
1.03904000000000
1.04153000000000
1.04400000000000
1.04347000000000
1.04463000000000
1.04481000000000
1.04540000000000
1.04500000000000
1.04573000000000
1.04578000000000
1.04658000000000
1.04688000000000
1.04589000000000
1.04639000000000
1.04630000000000
1.04536000000000
1.04569000000000
1.04389000000000
1.04594000000000
1.04538000000000
1.04644000000000
1.04532000000000
1.04586000000000
1.04569000000000
1.04523000000000
1.04588000000000
1.04485000000000
1.04579000000000
1.04577000000000
1.04507000000000
1.04593000000000
1.04629000000000
1.04449000000000
1.04569000000000
1.04572000000000
1.04623000000000
1.04544000000000
1.04389000000000
1.04679000000000
1.04556000000000
1.04596000000000
1.04442000000000
1.04601000000000
1.04491000000000
1.04638000000000
1.04462000000000
1.04451000000000
1.04550000000000
1.04536000000000
1.04535000000000
1.04594000000000
1.04435000000000
1.04519000000000
1.04523000000000
1.04621000000000
1.04599000000000
1.04577000000000
1.04516000000000
1.04613000000000
1.04636000000000
1.04555000000000
1.04544000000000
1.04543000000000
1.04523000000000
1.04522000000000
1.04667000000000
1.04574000000000
1.04425000000000
1.04563000000000
1.04627000000000
1.04467000000000
1.04594000000000
1.04645000000000
1.04613000000000
1.04522000000000
1.04593000000000
1.04610000000000
1.04582000000000
1.04540000000000
1.04569000000000
1.04572000000000
1.04546000000000
1.04521000000000
1.04589000000000
1.04644000000000
1.04477000000000
1.04472000000000
1.04597000000000
1.04579000000000
x data
1.21000000000000
1.21500000000000
1.22000000000000
1.22500000000000
1.23000000000000
1.23500000000000
1.24000000000000
1.24500000000000
1.25000000000000
1.25500000000000
1.26000000000000
1.26500000000000
1.27000000000000
1.27500000000000
1.28000000000000
1.28500000000000
1.29000000000000
1.29500000000000
1.30000000000000
1.30500000000000
1.31000000000000
1.31500000000000
1.32000000000000
1.32500000000000
1.33000000000000
1.33500000000000
1.34000000000000
1.34500000000000
1.35000000000000
1.35500000000000
1.36000000000000
1.36500000000000
1.37000000000000
1.37500000000000
1.38000000000000
1.38500000000000
1.39000000000000
1.39500000000000
1.40000000000000
1.40500000000000
1.41000000000000
1.41500000000000
1.42000000000000
1.42500000000000
1.43000000000000
1.43500000000000
1.44000000000000
1.44500000000000
1.45000000000000
1.45500000000000
1.46000000000000
1.46500000000000
1.47000000000000
1.47500000000000
1.48000000000000
1.48500000000000
1.49000000000000
1.49500000000000
1.50000000000000
1.50500000000000
1.51000000000000
1.51500000000000
1.52000000000000
1.52500000000000
1.53000000000000
1.53500000000000
1.54000000000000
1.54500000000000
1.55000000000000
1.55500000000000
1.56000000000000
1.56500000000000
1.57000000000000
1.57500000000000
1.58000000000000
1.58500000000000
1.59000000000000
1.59500000000000
1.60000000000000
1.60500000000000
1.61000000000000
1.61500000000000
1.62000000000000
1.62500000000000
1.63000000000000
1.63500000000000
1.64000000000000
1.64500000000000
1.65000000000000
1.65500000000000
1.66000000000000
1.66500000000000
1.67000000000000
1.67500000000000
1.68000000000000
1.68500000000000
1.69000000000000
1.69500000000000
1.70000000000000
1.70500000000000
  2 comentarios
Walter Roberson
Walter Roberson el 1 de Jun. de 2018
When you see R or L passing through zero like that, and the range being pretty much symmetric, then the values should be considered garbage.
You get the large range of R and L values like that because it is only possible to obtain the ratio R/L for the reasons I explained below: that any constant multiple of both of them gives the same ratio.
edo mor
edo mor el 1 de Jun. de 2018
but the fit line dosen't agree with the data and i dont know how to make it fit

Iniciar sesión para comentar.

Respuestas (2)

Star Strider
Star Strider el 2 de Jun. de 2018
If you provide a delay offset for ‘x’ (that is, ‘t’) it will provide an acceptable fit:
vfcn = @(b,x) b(1).*(1-exp(-(x+b(4)).*(b(2)./b(3))));
vftns = @(b) norm(v - vfcn(b,t));
opts = optimoptions('ga', 'PopulationSize',5000, 'InitialPopulationMatrix', randi(1000, 5000, 4))
[B,fval] = ga(vftns, 4, [], [], [], [], [1 1 1 -Inf], [1 1 1 1]*Inf, [], [], opts)
figure(1)
plot(t,v, 'p')
hold on
plot(t, vfcn(B,t), '-r')
grid
B =
1.0479e+000 640.7085e+000 9.3901e+000 -1.2070e+000
fval =
153.3155e-003
I cannot get ga (link) to provide an acceptable fit without adding the time-delay parameter, ‘b(4)’.

Walter Roberson
Walter Roberson el 1 de Jun. de 2018
To fit
YourData = V*(1-exp(-x*(R/L)))
then we need the vector of independent variables (presumably x).
Unless you have a second independent variable:
  • if x is your independent variable you can find R/L but not either alone
  • if R is your independent variable you can find x/L but not either alone
  • if L is your independent variable you can find x*R but not either alone
g = fittype('V*(1-exp(-x*RoL))');
result = fit((1:length(YourData)).',YourData,g)
result =
General model:
result(x) = V*(1-exp(-x*RoL))
Coefficients (with 95% confidence bounds):
RoL = 0.3373 (0.3227, 0.352)
V = 1.048 (1.044, 1.052)
Here, RoL is the ratio R/L . You cannot distinguish the two because for any non-zero constaint A, (A*R)/(A*L) = R/L, so increasing both by the same factor would give you the same fit.
  3 comentarios
edo mor
edo mor el 1 de Jun. de 2018
this is exactly what i got in cftool but the fit line dosent agree with the data
Walter Roberson
Walter Roberson el 2 de Jun. de 2018
None the less, that is the closest fit of the data to the model.
I ran a quite different fitting routine against that model, and found that to within a relative small margin, the parameters are 1.28450098237226129, 1.09411994131928014 . I had my routine search a pretty large parameter space.
The implication is that that equation does not fit that data.
If you examine the graph of your data, you can see that it must approach 0 somewhere close to t = 1.2. But that model approaches 0 at t = 0 and climbs rapidly from there.
Now, if you change the model to
v = V*(1-exp(-(t-t0)*(R/L)))
and search for V, R/L, and t0, then you can get excellent agreement
V = 1.04564508272744927; RoL = 88.8009466750188494; t0 = 1.20838792927323047;
f = @(t) V*(1-exp(-(t-t0)*RoL));
plot(t, v, 'k--', t, f(t), 'b.')

Iniciar sesión para comentar.

Categorías

Más información sobre Circuits and Systems en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by