closest number to a treshold and greater than it
7 ビュー (過去 30 日間)
古いコメントを表示
for example
i have
r1=0.9 r2=1.1 r3=1.2
i want to to know the r' that is nearest of 1 but greater than it.
0 件のコメント
回答 (2 件)
Image Analyst
2013 年 7 月 8 日
Is this homework? What have you tried? Have you tried subtracting 1 from the numbers and see which has the smallest difference greater than 0?
diff1 = r1-1;
diff2 = r2-1;
diff3 = r3-1;
1 件のコメント
Image Analyst
2013 年 7 月 8 日
r = [0.8, 21.1, 3.9]; % Sample data
differences = r-1
differences(differences<0) = inf % Set <1 = to infinity.
[minValue, indexAtMin] = min(differences(differences>1))
参考
カテゴリ
Help Center および File Exchange で Other Formats についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!