Calibration optimization with fminunc or/and lsqcurvefit
1 次查看(过去 30 天)
显示 更早的评论
Dear MatLab community,
I have the following simplified measurement model:
- m = C*f - b
where
- m = [m_x, m_y, m_z] is the 3x1 true (reference) measurement vector at the jth time epoch
- C is the 3x3 calibration matrix
- f = [f_x, f_y, f_z] is the 3x1 synthetic or measured measurement vector at the jth time epoch
- b is the 3x1 bias offset vector
In the optimization algorithm my known quantities are the magnitude time series of true readings norm(m) and the synthetic time series f. The unknown quantities are the components of C and b. I would like to create calibration algorithm with fminunc or/and lsqcurvefit to determine the latter.
In general my objective function looks like this:
- epsilon = sum_{j=1}^{n} ( ( C*(f_j) - b )^{T} * ( C*(f_j) - b ) - (m_j)^{T}*(m_j) )
where n is the total number of the measurements.
I am trying to solve this optimization problem with lsqcurvefit and fminunc and I have several questions. See my code in the attachment.
(1) These function is good for my purpose?
(2) I can not tune correctly the lsqcurvefit optimization. If my initial guesses is not the around the actual pre-defined coefficients, then MaxFunEvals exceeds its default limit. If I set it to higher value I got the same message. Could someone hint an idea, how could I get a local minimum.
(3) For fminunc I got the following message: fminunc stopped because it cannot decrease the objective function along the current search direction. What options should I modify?
(4) I can analytically provide the gradient and the hessian of the objective function. However they are depend on the other two input data (f,m). How can I supply fminunc with this information? I created something like this:
function [f,g,H] = myfun(x,xdata,ydata)
f = f(x,xdata,ydata) % Compute the objective function value at x
if nargout > 1 % fun called with two output arguments
g = df_dx(x,xdata,ydata) % Gradient of the function evaluated at x
if nargout > 2
H = df2_dx2(x,xdata,ydata) % Hessian evaluated at x
But in the the main program it does not work.
opts2 = optimset('Display','iter','Algorithm','active-set','GradObj','on','Hessian','on');
[xunc2,fval2,exitflag2,output2,grad2,hessian2] = fminunc(@myfun,x0,opts2);
Or fminunc function only have one x input variable?
Any advice and suggestions will be greatly appreciated.
Adam
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!