Borrar filtros
Borrar filtros

set the threshold value by percentage

7 visualizaciones (últimos 30 días)
muhammad faiz
muhammad faiz el 22 de Feb. de 2017
Comentada: Jan el 23 de Feb. de 2017
Hi, if i have 2 matrices A and B. A=rand(1,2) B=rand(10,2)
how do i find a point B where the distance to points A is closest, and i do not what the min value (distances). i would like to find something like "find distances that is higher 30 percent than the min value of the distances". please, how to do just that?
thank you.

Respuestas (1)

Jan
Jan el 22 de Feb. de 2017
Editada: Jan el 22 de Feb. de 2017
Start with finding the distances:
A = rand(1,2);
B = rand(10,2);
Dist = sqrt(sum((A - B).^2, 2));
Then determine the minimum and add 30%:
searched = min(Dist) * 1.3;
Now search the distance, which is nearest to searched:
[~, Index] = min(abs(Dist - searched));
Finally Index is the row of B, which is nearest to 130% of the minimum distance.
  2 comentarios
muhammad faiz
muhammad faiz el 22 de Feb. de 2017
hai, thanks for the helps, but may i know, why there is no change in Index value when i change the percentage to maybe 1.4 or 1.5? however, when i change to higher value (e.g 1.8 or 2.0), the Index is changed.
Jan
Jan el 23 de Feb. de 2017
This depends on the data. If the value, which is nearest to 130% is the nearest to 150% also, you get the same index. The smaller B is, the higher is the chance to get the same result for e.g. 130% and 140%. Try it with B = rand(1000, 2).

Iniciar sesión para comentar.

Categorías

Más información sobre Operators and Elementary Operations 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