View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

3.4 | 6 ratings Rate this file 11 Downloads (last 30 days) File Size: 1.48 KB File ID: #22042 Version: 1.0
image thumbnail



Kevin Moerman (view profile)


Fits a plane to 3D data using singular value decomposition

| Watch this File

File Information

Fits a plane of the from z=Ax+By+C to the data and provides the coefficients A,B and C. The functions uses the svd command (singular value decomposition).

a=1; b=2; c=-2;
x=x(:); y=y(:); z=z(:);
plot3(x,y,z,'r.'); hold on; grid on;
surf(X,Y,Z,'FaceColor','g'); alpha(0.5);
title(['a=',num2str(a), ', A=',num2str(A),', b=',num2str(b),', B=',num2str(B),', c=',num2str(c),', C=',num2str(C)]);


This file inspired Threepoints2planez.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
18 Feb 2017 Arman Rezaee

17 Mar 2015 x I'm tc

Doesn't seem to work, but perhaps it is not doing what I hope it is doing.

06 Dec 2014 Meghana Dinesh

Hi, I want to use your code for my project.

But I have a problem with it.........I am not familiar with this topic though. I'm not sure I am using my outputs from this function in the right way to plot my plane.

I have posted this on

Please let me know if you need additional information.

Although your function fits properly with my data points, the angle detected between two planes does not seem right.

Thank you.

Comment only
22 Aug 2012 Nathan Tomlin

27 Nov 2008 Jan Neggers

It worked perfectly for me. Although i didn't understand SVD and therefore tried it with a least squares method, which also works.

17 Nov 2008 Gavrilo Bozovic

Didn't work for me, and the data was as planar as one could expect it to be...

17 Nov 2008 Gavrilo Bozovic

Contact us