필터 지우기
필터 지우기

set the threshold value by percentage

조회 수: 7 (최근 30일)
muhammad faiz
muhammad faiz 2017년 2월 22일
댓글: Jan 2017년 2월 23일
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.

답변 (1개)

Jan
Jan 2017년 2월 22일
편집: Jan 2017년 2월 22일
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
muhammad faiz
muhammad faiz 2017년 2월 22일
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 2017년 2월 23일
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).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by