I believe what is desired here is how to calculate the Euclidean distance for a vector without using a do loop to run through all the indexes.
This can be achieved easily (it's one of the beauties of MATLAB) with the dot multiply command. In addition to the standard matrix mathematics, MATLAB offers a set of dot matrix commands that operate on matrices element by element.
Let me provide an example. Assume a and b are vectors (1 by N or perhaps N by 1). All that matters is that they have the same dimensions.
Then ab is certainly the vector difference. Now we have to do the root sum square, and this is where the dot multiply is appropriate.
(ab).*(ab) is a vector of the squares of the elements. We just take the sum as
sum((ab).*(ab))
Now we have a single number and we're ready to take the square root, so
Euclidean distance = sqrt( sum((ab).*(ab)) )
You may also be able to use some variant of the norm command. Either way is fairly easy and does not require the user to do any loops.
Is this what you were after?
"Ken Davis" <kendavis@alum.mit.edu> wrote in message <F6E1E2BF45EC8E39C1F1576F139CF8B1@in.webcrossing.raydaftYaTP>...
> "Krishna" <krishna.pillai@gmail.com> wrote in message
> news:1184924538.758486.298140@z24g2000prh.googlegroups.com...
> >>> a = [1 2 3; 4 5 6; 7 8 9]
> >>> b = [ 8 3 4; 5 4 6; 5 6 7]
> >>> d = mean(abs(ab),1)
> >
> > helps?
> >
> > Krishna
> > http://dsplog.blogspot.com
> >
>
> Euclidean distance is the square root of the sum of the squares of the
> individual components of two vectors (points in Euclidean Nspace).
>
>
