"Hero Lee" <hero@mathworks.com> wrote in message <gnq6hq$ald$1@fred.mathworks.com>...
> Hi, Dear Sir or Madam,
>
> There are a number of data sets (x, y, z) locating in a 3Dimensional sapce, and I would like to generate a table (or a matrix) displaying the corresponding value of Eulidean Distance between each data set in the 3Dimensional sapce. For example,
> A(0,0,0), B(1,0,0), C(1,2,0)....N(Xn,Yn,Zn) are locating in a 3Dimensional sapce, so the table (or a matrix) can be represented as follows:
>
> A B C ... N
> A 0 1 2.23 ... Sqrt(A^2N^2)
> B 1 0 2 ... Sqrt(B^2N^2)
> C 2.23 2 0 ... Sqrt(C^2N^2)
> . . . . ...
>
> N . . . ... 0
>
> Also, I would like to calculate the average value of the total value in the table.
> Hence, please kindly give me a sample code. Really thank you so much.
>
> Cheers,
For simplicity let's suppose the points are located in an N x 3 array called M. Call the H x N array of distances D.
[I,J] = ndgrid(1:N,1:N);
D = reshape(sqrt(sum((M(I,:)M(J,:)).^2,2)),N,N);
Roger Stafford
