Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Fitting a plane

Subject: Fitting a plane

From: Rachit

Date: 20 May, 2010 18:38:04

Message: 1 of 4

Hello All,

I am trying to fit a plane using a set of (X,Y, Z ) co-ordinates.I am relatively new to matlab can anyone suggest me how to go ahead with the same?

Subject: Fitting a plane

From: Matt J

Date: 20 May, 2010 19:03:04

Message: 2 of 4

See this thread

http://www.mathworks.com/matlabcentral/newsreader/view_thread/263635#688424

Subject: Fitting a plane

From: Roger Stafford

Date: 20 May, 2010 19:04:04

Message: 3 of 4

"Rachit " <racpsine@gmail.com> wrote in message <ht3vic$134$1@fred.mathworks.com>...
> Hello All,
>
> I am trying to fit a plane using a set of (X,Y, Z ) co-ordinates.I am relatively new to matlab can anyone suggest me how to go ahead with the same?
- - - - - - - -
  If you want to minimize the sum of the squares of the orthogonal distances from the points to a plane, then you can use the 'svd' function. Let us suppose that X, Y, and Z are corresponding column vectors.

 xm = mean(X); ym = mean(Y); zm = mean(Z);
 [U,S,V] = svd([X-xm,Y-ym,Z-zm],0);

Then the best-fitting plane in the above sense is given by the equation

 V(1,3)*(x-xm) + V(2,3)*(y-ym) + V(3,3)*(z-zm) = 0

The indicated V(:,3) is the eigenvector corresponding to the smallest singular value in S and represents the best fit.

Roger Stafford

Subject: Fitting a plane

From: Walter Roberson

Date: 20 May, 2010 19:09:04

Message: 4 of 4

"Rachit " <racpsine@gmail.com> wrote in message <ht3vic$134$1@fred.mathworks.com>...

> I am trying to fit a plane using a set of (X,Y, Z ) co-ordinates.I am relatively new to matlab can anyone suggest me how to go ahead with the same?

I am not certain that there will usually be a unique solution, but it will depend what you mean.

What properties do you expect the fitted plane to have? For example, imagine that I supply coordinates for points lying in two planar squares of the same size and X Y positions, with those two planes parallel to each other in Z: then were would you want the fitted plane to lie? Half-way between the two squares and parallel to them? Diagonally through the corners of the two squares so as to maximize the number of points in each of the squares that is passed through? In the same plane as one of the squares so as to maximize the total number of original points passed through?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us