Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!s4g2000yql.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Point with the closest distance
Date: Mon, 2 May 2011 14:13:37 -0700 (PDT)
Organization: http://groups.google.com
Lines: 20
Message-ID: <8df53692-8a1d-42e7-99da-b1326544ef13@s4g2000yql.googlegroups.com>
References: <iplj54$c3t$1@fred.mathworks.com> <ipmgel$482$1@fred.mathworks.com>
 <41a34a6d-b68d-44e2-8352-9e696d33341a@d19g2000prh.googlegroups.com> <ipn0s6$gdn$1@fred.mathworks.com>
NNTP-Posting-Host: 184.57.134.178
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1304370817 4319 127.0.0.1 (2 May 2011 21:13:37 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 2 May 2011 21:13:37 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: s4g2000yql.googlegroups.com; posting-host=184.57.134.178; posting-account=0rLUzAkAAABojYSRC64DkTbtiSCX77HH
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1,gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:724857

On May 2, 3:32 pm, "Deepak " <deepak....@gmail.com> wrote:
> Now i need to find the closest point from the axis to the point cloud.
------------------------------------------------------------------------------------
I'm not sure why you didn't try my sorting suggestion.  Any reason?
Just add this to the end of your code:

% Plot it
scatter3(X(:,1), X(:,2), X(:,3));

% Calculate radius squared.
radiiSquared = X(:,1).^2 + X(:,2) .^2
% Sort from smallest radius to largest radius.
[sortedRadii, sortIndexes] = sort(radiiSquared)
% Create the output array.
output = X(sortIndexes, :)

It's a simple matter to subtract off the value of the origin (your
least squares center line) to get the radii squared in case you want
to do that.