Fit multivariable objective function using fminsearch
6 ビュー (過去 30 日間)
古いコメントを表示
I have been trying to fit bi-exponential function with 4 variables using fminsearch. I am having difficulty to formulate it in correct way. can you please help me to work it out. (The code is successfully run for lsqnonlin but results are very unreasonable)
b=[50 400 800]; ydata=[850 400 90];
f=@(x,b) x(1)*(x(2)*exp(-x(3)*b)+(1-x(2))*exp(-x(4)*b));
x0=[950,0.3,0.002,0.01];
options = optimset('MaxFunEvals',1e9,'MaxIter',1e9,'TolFun', 1e-8, 'TolX', 1e-8);
X=fminsearch(f,x0,options);
0 件のコメント
採用された回答
Star Strider
2015 年 10 月 15 日
You cannot do what you want. You have three data pairs, so you can fit a maximum of three parameters, not the four you want to fit. (Consider fitting a line that requires two parameters — slope and intercept — through a point — one data pair. You can fit an infinite number of lines, all of which are ‘correct’.) You do not know what your data are except where you measure them, so interpolating to create more ‘data’ is not an acceptable solution. So regardless of the solver you use, you are not going to get reliable parameter estimates.
You are also missing a cost function in your code. You need to minimise this instead of ‘f’:
SSECF = @(x) sum((f(x,b)-ydata).^2); % Sum-Squared-Error Cost Function
X=fminsearch(SSECF,x0,options);
You still will not get reliable parameter estimates, but at least the code will be correct!
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!