필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
John Hunt
John Hunt 2017년 10월 25일
편집: Matt J 2017년 10월 25일
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?

답변 (1개)

Matt J
Matt J 2017년 10월 25일
편집: Matt J 2017년 10월 25일
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

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by