3-D line of best fit from origin to cloud of data points

40 views (last 30 days)
I'm trying to get a line of best fit for a 3-D set of data points. This line of fit should go from the origin to the "cloud" of points, and I'd like to know the equation for that fit. Any ideas?
Thanks

Answers (1)

Matt J
Matt J on 3 Dec 2019
Edited: Matt J on 3 Dec 2019
The equation is t*u where u is 3D line direction vector obtained by,
[V,d]=eig(A.'*A,'vector');
[~,i]=max(d);
u=V(:,i);
and A is an Nx3 matrix whose rows are your cloud points.
  6 Comments
Matt J
Matt J on 13 Nov 2021
@Chang hsiung You're quite welcome. Please accept-click the answer if it helped you.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!