File Exchange

image thumbnail


version (1.43 KB) by Val Schmidt
A function to fit a plane to a 3D point cloud.


Updated 24 Apr 2012

View License

Given the equation of a plane as z = a*x + b*y + c, planefit, executed as C = planefit(x,y,z), solves for the coeficients C = [a b c]. Planefit does nothing fancy, it simply sets up and lets MATLAB solve the least-squares problem to solve for the coefficients - a handy utility function.

Cite As

Val Schmidt (2021). planefit (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (11)

Val Schmidt

I guess it never occurred to me.

Pablodc Pablodc

Hello. I congrats you. I Have a question. Why do you set the plane equation as z=Ax+By+C? This way you are not allowing any plane parallel to z axis.

Val Schmidt

LMS, Create any two vectors that lie within the plane and calculate their cross-product. That would give you a vector orthogonal to both.


Very useful! What's the easiest way to calculate the plane normal, please?

Val Schmidt

Rose Ann, I'm afraid I don't understand your question.

Suzie Oman

Is the multiplier on Z 1 or 0?

Zhoushun Ruan


Val Schmidt

It is possible that I don't fully understand what you are attempting to do, but it seems to me you must have 3 points to define any plane and having just two will not be sufficient to find a third.


I am having issues using this code. Please help me out...

What I am trying to do:
1)use existing points to define a plane
2)using the plane solve for the location of new points knowing 2 out of 3 of the coordinates and solving for the third using the equation from planefit....

But I cant get planefit to work


MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Inspired: threepoints2planez

Community Treasure Hunt

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

Start Hunting!