how to find cityblock distance?

5 visualizaciones (últimos 30 días)
hp
hp el 2 de Oct. de 2018
Comentada: Rik el 16 de Feb. de 2023
how to find the city block distance between feature vectors to query image feature vector, in matlab2013?

Respuestas (3)

Jan
Jan el 2 de Oct. de 2018
pdist and pdist2 can calculate the city block distance.

Fowzi barznji
Fowzi barznji el 16 de Mzo. de 2020
x=[1 3 9 6 4 2 6 8 3 6];
y=[4 -2 6 8 8 3 7 2 1 1];
cityblockvalue = sum((abs(x - y)));
cityblockvalue= 32
  7 comentarios
DGM
DGM el 10 de En. de 2023
b is not a vector. It depends what the relationship between a and b is.
Assuming that a is a row vector and applies in whole to each row of b in the same way, then the distance for each row is:
x = [1 2 3];
y = [4 5 6; % i made this 4x3 so that it's easy to see the orientation
7 8 9;
10 11 12;
13 14 15];
D = pdist2(x,y,'cityblock').'
D = 4×1
9 18 27 36
D = sum((abs(x - y)),2) % works R2016b+
D = 4×1
9 18 27 36
rema
rema el 16 de Feb. de 2023
thank you

Iniciar sesión para comentar.


Fowzi barznji
Fowzi barznji el 16 de Mzo. de 2020
  2 comentarios
rema
rema el 16 de Feb. de 2023
hi,how obtain on lable image for using in classification by using knn
Rik
Rik el 16 de Feb. de 2023
@rema You're asking a completely new question. Have a read here and here. It will greatly improve your chances of getting an answer.

Iniciar sesión para comentar.

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by