0

I have a set of data, which is distributed like on the picture below. data

It clearly looks, like a function:

k1*(1-e^(-t/T1))-k2*(1-e^(-t/T2)).

Is there a method provided in Matlab, to estimate parameters in this kind of function or do you have any ideas of estimating them in code to avoid doing it 'manually'? Thanks.

2 Answers2

2

You're looking for non linear optimisation.

Check the curve fitting toolbox, never used it but it seems to have exponential fitting.

Otherwise you could define your own target function f(k1,k2,T1,T2) (usually the mean squared error between your desired curve and your data ). Then you apply an optimization algorithm to minimise the error ( fminsearch() works good enough ).

xvan
  • 4,554
  • 1
  • 22
  • 37
  • Thanks, I used curve fitting toolbox and noticed, that function, which i wanted to use didn't fit well enough to my data, so i tried different custom functions inside the toolbox. When I figured out, which one is the best I made my own target function with mean square error and estimated parameters in the code. It worked verry good, so thanks again for both advices. – user2638817 Jul 18 '16 at 21:47
2

If you want to do it within a script you can do the following:

ft = fittype( 'a*(1-exp(-t/b))-c*(1-exp(-t/d))', 'coefficients',{'a','b', 'c', 'd'},...
'independent', 't', 'dependent', 'y' ); 
f = fit(xValues, yValues, ft);

with f.a, f.b ... you can get the parameter values. You can also adjust more settings see fit func at Mathworks

v.tralala
  • 1,444
  • 3
  • 18
  • 39