Count rows > target value

6 ビュー (過去 30 日間)
Stef
Stef 2018 年 5 月 26 日
回答済み: Ameer Hamza 2018 年 5 月 26 日
I have a matrix A with observations (only two in the example) in the rows and features (five in the example) in the columns. I want to find the number of rows where any element is larger than the target value in vector b.
A = [1,2,3,4,5 ; 5,5,5,5,5]
b = [2,3,4,5,6]
I tried it with this code
length(find(A > b))
But then the answer is 3, since the first row is ok, but in the second row, three elements in A exceed the correpsonding elements in b. However, I just want to have them count as 1 row and not as 3.

採用された回答

Ameer Hamza
Ameer Hamza 2018 年 5 月 26 日
sum(any(A>b, 2))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by