Find the number of times a number is in an array for every column

1 回表示 (過去 30 日間)
NMans
NMans 2018 年 6 月 21 日
回答済み: Fangjun Jiang 2018 年 6 月 21 日
Hi, this is probably quite simple but can't get my head around it. I have 8784 x 9 matrix and I want to find value <= 0 in this matrix for each column and save the answer as a new matrix of 1 x 9. I've started with this:
[nrow, ncol] = size (matrix)
for k = 1:ncol
newMatrix = find(matrix =>0)
end
This ends up giving me just 1 column instead of 9 columns. Eventually I want to use the number of times the value of 0 (or less) occurs in each column as part of my next calculation. Can anybody help? Thanks!

採用された回答

Fangjun Jiang
Fangjun Jiang 2018 年 6 月 21 日
Hope this give you a clue
a=rand(3,9)-0.5;
b=a<=0;
c=sum(b)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by