Failure in initial objective function evaluation. LSQNONLIN cannot continue.
이전 댓글 표시
I am getting the LSQNONLIN error and I am hoping that someone can take a look at my objective function. I am sure I have written it completely wrong.
x will be an input vector of [rx ry rz mx my mz]. And what I would like to get out of this are the optimized values for [rx ry rz mx my mz].
G_measured calls a function that takes in a vector called Rmeasured and dipoleMoment and spits out data of 4x6 vector (4 measurement points measuring G elements), same with G_estimate.
Any help or guidance would be appreciated as I am fairly new to this.
options = optimoptions(@lsqnonlin);
options.Display = 'iter';
options.Algorithm = 'levenberg-marquardt';
options.StepTolerance = 1e-6;
options.MaxFunctionEvaluations = 1000;
x = lsqnonlin(@lm_obj,x_init, [],[],options)
x_init = [1, 3, 5, 10, 0, 10]
function F = lm_obj(x)
G_estimate = getGradientsEstimate(x);
G_measured = getGradientsMeasured(Rmeasured, dipoleMoment)
Difference = G_estimate - G_measured;
F = norm(Difference)
end
댓글 수: 3
Ameer Hamza
2020년 9월 4일
First, the correct orders of statements should be like this
x_init = [1, 3, 5, 10, 0, 10]; % initialized first
x = lsqnonlin(@lm_obj,x_init, [],[],options)
The error is caused by the functions getGradientsEstimate or getGradientsMeasured. How are they defined? What is the value of dipoleMoment, and where is it defined?
sree chak
2020년 9월 4일
Ameer Hamza
2020년 9월 5일
getGradientsEstimate() needs 3 input variables, whereas you are only passing in one variable. I guess the vector x_init combines the value of sensorLoc, targetLoc, and dipoleMoment, but you need to split x vector into 3 variables and then pass it to these functions.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Digital Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!