Effacer les filtres
Effacer les filtres

set the threshold value by percentage

7 vues (au cours des 30 derniers jours)
muhammad faiz
muhammad faiz le 22 Fév 2017
Commenté : Jan le 23 Fév 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.

Réponses (1)

Jan
Jan le 22 Fév 2017
Modifié(e) : Jan le 22 Fév 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 commentaires
muhammad faiz
muhammad faiz le 22 Fév 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 le 23 Fév 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).

Connectez-vous pour commenter.

Catégories

En savoir plus sur Operators and Elementary Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by