Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: Fitting a plane Date: Thu, 20 May 2010 19:04:04 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 17 Message-ID: <ht4134$e6v$1@fred.mathworks.com> References: <ht3vic$134$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1274382244 14559 172.30.248.35 (20 May 2010 19:04:04 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Thu, 20 May 2010 19:04:04 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:637730 "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