How to minimize a midpoint of a 3D line to a 3D data set?

1 vue (au cours des 30 derniers jours)
John Hunt
John Hunt le 25 Oct 2017
Modifié(e) : Matt J le 25 Oct 2017
I have two points pt1 = (36.77, 11.63, -38.82) pt2 = (31.77, 14.61, -31.09). I also have a set of data points that I need to use to "connect" these two points.
a = [44.16 17.609 -28.523;
43.491 15.957 -30.258;
45.491 16.502 -31.569;
45.337 17.206 -33.948;
44.864 14.849 -33.304]
I wanted to connect the points by first making a line between them. I can use the two points to make a vector that would connect them, then I can divide that in half and then find the midpoint between these points. Once I have the mid point I want to "move" it so that it resides "in" the data. To move it in I was going to find the smallest distance from the midpoint of the line and a data point then move the midpoint there. I want to iterate this until I have enough lines that fit the data well. I wanted to do this with fmincon, but I am having a hard time with the parameters. Any suggestions?

Réponses (1)

Matt J
Matt J le 25 Oct 2017
Modifié(e) : Matt J le 25 Oct 2017
You don't need fmincon for something so simple as finding separation distances of points. It can all be done algebraically,
mindpoint=(pt1+pt2)/2;
[minDistance,minloc]=min(sum( (a-midpoint).^2 ,2) ), %R2016b or higher

Catégories

En savoir plus sur Least Squares dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by