Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!news.glorb.com!postnews.google.com!t8g2000yqg.googlegroups.com!not-for-mail
From: TideMan <mulgor@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Calculate distance between points
Date: Wed, 25 Jan 2012 13:26:29 -0800 (PST)
Organization: http://groups.google.com
Lines: 34
Message-ID: <059d883f-d700-4e04-af38-cec851ddb483@t8g2000yqg.googlegroups.com>
References: <jfppkm$ke1$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: 202.78.152.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1327526790 31381 127.0.0.1 (25 Jan 2012 21:26:30 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 25 Jan 2012 21:26:30 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: t8g2000yqg.googlegroups.com; posting-host=202.78.152.105; posting-account=qPexFwkAAABOl8VUndE6Jm-9Z5z_fSpR
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: HUALESRCNK
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:755800

On Jan 26, 9:45 am, "Tan Has" <tanzeerha...@gmail.com> wrote:
> Hi I am very new in matlab. Can any body help me to figure it out?
>
> Lets, I have a matrix (10 X 20), I want to calculate the distance of each point of the matrix from one certain point (another array of xy point). I want to check the distance of all points in the matrix with respect to xy point (first with respect to 1st xy coordinate then 2nd and to the end.) I want to use the loop system.
>
> Example data:
> (X1, Y1)  (x1, y1)
> (X2, Y2)  (x2, y2)
> (X3, Y3)  (x3, y3)
> (..., ....)  (..., ....)
> (..., ....)  (..., ....)
> (..., ....)  (..., ....)
> (Xn, Yn)  (xm, ym)
>
> for I = 1, n
> for I = 1, m
> dist=sqrt((X(I)-x(I))^2+(Y(I)-Y(I))^2)
> end
> end
>
> IS THIS THE CODE???
>
> Thanks a lot.

No it won't work.
But I cannot figure out what your matrix is.
You gave us example data, but it makes no sense in Matlab parlance.
You also said the matrix was 10x20, but where are the 20 columns?  You
only showed 4.