Azzera filtri
Azzera filtri

set the threshold value by percentage

7 visualizzazioni (ultimi 30 giorni)
muhammad faiz
muhammad faiz il 22 Feb 2017
Commentato: Jan il 23 Feb 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.

Risposte (1)

Jan
Jan il 22 Feb 2017
Modificato: Jan il 22 Feb 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 Commenti
muhammad faiz
muhammad faiz il 22 Feb 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 il 23 Feb 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).

Accedi per commentare.

Categorie

Scopri di più su Operators and Elementary Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by