comparing the maximum value of a matrix to the other values
1 回表示 (過去 30 日間)
古いコメントを表示
Hello, I have a question. I need to compare the maximum value in an array to the other elements in an array and check if it is greater than 1.2 times the other elements. How can I do this in matlab? I'd prefer it if it is a simple command since I'm already doing this within a loop. I know max will give me the maximum but how to compare it with the other elements?
0 件のコメント
回答 (2 件)
Walter Roberson
2017 年 12 月 29 日
If you want to know whether it is greater than 1.2 for all of the elements, then
if max(FirstArray) > 1.2 * max(SecondArray)
If you want to know whether it is greater than 1.2 for some element then
if max(FirstArray) > 1.2 * min(SecondArray)
I recommend that you explicitly comment the behavior you want when some of the values in the second array might be negative. Is -1.3 "greater than" 1.2 times -1 because the value has greater distance from 0 ?
5 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!