Customising the lsqcurvefit function for an user defined error metric??

10 views (last 30 days)
I am currently trying to use a Levenberg-Marquardt solver with the lsqcurvefit function for the registration(Minimization stage) of 2 point clouds.
I am able to modify the objective function of the lsqcurvefit, and obtain a good fit.
But for my application, I would like the change the error metric on which the solver works on. If I my understanding is right, the solver works on minimizing the squared deviations between the 2 data sets. I would like to add another term into the error, and let the solver minimize the new error metric. Does the lsqcurvefit allow such modifications?
Thank you in advance!
  2 Comments
Torsten
Torsten on 11 Aug 2017
Which kind of error modification do you want to introduce ?
Best wishes
Torsten.
Guruprasad
Guruprasad on 11 Aug 2017
Edited: Guruprasad on 11 Aug 2017
Thank you Torsten for your reply.
I have a set of points which are a part of my actual data set(known already). I would like to introduce more weights on the deviations on these points, when compared to the other points.
So, if I could include, a term which could increase the error more for deviations on these points, I believe these points would be considered as priority.
I am also open to other suggestions for implementation.
Thank you,
Guru.

Sign in to comment.

Accepted Answer

Torsten
Torsten on 11 Aug 2017
Use "lsqnonlin" instead of "lsqcurvefit" and define the f_i as
f_i = sqrt(w_i)*(y_i-ydata_i)
where w_i is the weight for the deviation of the ith data point.
Best wishes
Torsten.
  3 Comments
Guruprasad
Guruprasad on 11 Aug 2017
Edited: Guruprasad on 11 Aug 2017
Thank you very much Torsten!
The "weights" solution works perfectly. The only problem is that I have close to 25000 points :D
Weighing the errors for every iteration of my registration loop makes it computationally expensive. Is there a way to make this faster?
Torsten
Torsten on 11 Aug 2017
But multiplying the residual vector by the weights is just
res=res.*sqrtw
where "sqrtw" can be set before the call to "lsqnonlin" and passed to the residual function as an argument. This should not take that much time.
Best wishes
Torsten.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!