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

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

Which kind of error modification do you want to introduce ?
Best wishes
Torsten.
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

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

And here is a suggestion if you want to stick to "lsqcurvefit":
https://de.mathworks.com/matlabcentral/newsreader/view_thread/42584
Best wishes
Torsten.
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?
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)

Asked:

on 11 Aug 2017

Commented:

on 11 Aug 2017

Community Treasure Hunt

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

Start Hunting!