Filter löschen
Filter löschen

i am trying to find the euclidean distance of 2 vector with different sizes

3 Ansichten (letzte 30 Tage)
T =
5.1000 3.5000 1.4000 0.2000
6.4000 3.2000 4.5000 1.5000
5.4000 3.4000 1.7000 0.2000
5.7000 2.8000 4.5000 1.3000
5.7000 4.4000 1.5000 0.4000
5.6000 2.9000 3.6000 1.3000
X =
5.5000 3.8000 1.9000 0.4000
6.4000 2.9000 4.3000 1.3000
4.3000 3.0000 1.1000 0.1000
5.4000 3.0000 4.5000 1.5000
I want to use this method to find euclidean distance for each row of T and X in such a way use the each row of X to T(6,4)
for example first row will be = sqrt ((5.5 - 5.1)^2 + ((3.5 - 3.8)^2 + ((1.4 - 1.9)^2 + 0.2 -0.4)^2....................first row to the 24th row ( the number of row to obtain is 24)
Kindly get back to me thank
  2 Kommentare
Adam
Adam am 8 Apr. 2019
The first row is clear enough, and up to the 4th row in your example posted above, but it's not clear what you are expecting where you have more rows in T than in X.
Tino
Tino am 8 Apr. 2019
Thanks for your swift response
I want use the first row of x and go through all the rows of T
second row will be = sqrt ((6.4 - 5.1)^2 + ((3.2 - 3.8)^2 + ((4.5 - 1.9)^2 + (1.5 - 0.4)^2
each row of X will give (6,4)
Kindly assist me in solving the ussue

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Guillaume
Guillaume am 8 Apr. 2019
Bearbeitet: Guillaume am 8 Apr. 2019
I'm also not clear on what you're asking. If you want to find the euclidean distance between each row of T and each row of X, then this is easily done:
T = [
5.1000 3.5000 1.4000 0.2000
6.4000 3.2000 4.5000 1.5000
5.4000 3.4000 1.7000 0.2000
5.7000 2.8000 4.5000 1.3000
5.7000 4.4000 1.5000 0.4000
5.6000 2.9000 3.6000 1.3000];
X = [
5.5000 3.8000 1.9000 0.4000
6.4000 2.9000 4.3000 1.3000
4.3000 3.0000 1.1000 0.1000
5.4000 3.0000 4.5000 1.5000];
distance = sqrt(sum((permute(T, [1 3 2]) - permute(X, [3 1 2])) .^ 2, 3))
distance(r, c) is then the distance between T(r, :) and X(c, :)

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by