How to skip the element that is 'inf' value where fitting a curve

6 ビュー (過去 30 日間)
KB
KB 2014 年 8 月 18 日
コメント済み: Star Strider 2014 年 8 月 19 日
Hello, I have been trying to get some constant values for a given set of experimental data. The fitting equation is below:
k*t = a-ln((Cm/C)-1) where a and k value needs to be find out. C is the output at different time t. Cm = maximum value of the C data at anytime t. So, obviously at some point ln((Cm/C)-1) is giving me 'inf' value and the procedure is not able to initiate at any initial guess of k and a value.
How to proceed with the problem for the solution. I have been trying using 'lsqcurvefit' which says 'Objective function is returning undefined values at initial point. lsqcurvefit cannot continue'

採用された回答

Star Strider
Star Strider 2014 年 8 月 18 日
編集済み: Star Strider 2014 年 8 月 18 日
I would use this equation for ‘Cfit’ as my objective function:
% b(1) = a, b(2) = k, <— Designate Parameter Vector ‘b’
Cm = ... % <— Supply a value for ‘Cm’
Cfit = @(b,t,Cm) Cm./(exp(b(1)-b(2).*t) + 1); % Objective Function
b0 = rand(2,1); % Initial Parameter Estimate
B = lsqcurvefit(@(b,t) Cfit(b,t,Cm), b0, t, C) % Estimate Parameters
a = B(1);
k = B(2);
That should work. (Tested with simulated data for ‘t’ and ‘C’.)
You needed to solve for ‘C’ as a function of ‘t’ to make it work. (It’s a three or four line derivation.)
  2 件のコメント
KB
KB 2014 年 8 月 19 日
Thank you. I am just wondering what is the purpose of using 'Cfit'? I have looked at Matlab documentation but still not clear to me.
Star Strider
Star Strider 2014 年 8 月 19 日
My pleasure!
‘Cfit’ is the function (as an anonymous function here) that fits your data. (It is known as the ‘objective function’ in nonlinear parameter estimation terms.) It is your original expression, solved for ‘C’ as a function of ‘t’, specifically:
C(t) = Cm /(exp(a-k*t)+1)
however it has to be stated slightly differently in anonymous function form, and in its use in lsqcurvefit, for it to work in MATLAB to fit your data. See the documentation on Anonymous Functions for details.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by