Borrar filtros
Borrar filtros

distance between vectors in matlab???

5 visualizaciones (últimos 30 días)
mmm ssss
mmm ssss el 3 de Abr. de 2012
hi
i have a vector of 85*1 size and a matrix contains 85*396.
i need to find the distance between the 85*1 vector and all the vectors(columns ) of the matrix gamma and returns the closest distance and the column that give me this distance , how can i do this by matlab ???
thanks for all

Respuesta aceptada

Titus Edelhofer
Titus Edelhofer el 3 de Abr. de 2012
Hi,
bsxfun is your friend:
x = rand(85, 1);
A = rand(85, 396);
dist = bsxfun(@minus, A, x);
dist2 = sqrt(sum(dist.*dist));
[mindist, column] = min(dist2);
Titus
  3 comentarios
Titus Edelhofer
Titus Edelhofer el 3 de Abr. de 2012
Hi,
x and A were just examples, I thought that the matrix (gamma) and the vector (features) are given. So: remove the first two lines above and start with the line dist = ..., if variables gamma and features are there ...
Titus
mmm ssss
mmm ssss el 3 de Abr. de 2012
O000k .but i think that measuring the similarity between the vectors by finding distances between them is not very good , isn't it ?can i know your opinion?

Iniciar sesión para comentar.

Más respuestas (1)

Thomas
Thomas el 3 de Abr. de 2012
doc boxdist
The box dist should give you distance between position vectors.
Follow the example given int he documentation
  2 comentarios
mmm ssss
mmm ssss el 3 de Abr. de 2012
thanks alot
mmm ssss
mmm ssss el 3 de Abr. de 2012
thanks alot

Iniciar sesión para comentar.

Categorías

Más información sobre Gamma Functions en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by