how can i count number of zeroes in a martix(containing elements 0s and 1s only) which is below any 1s(means in a column top to bottom , if 0 comes then dont count if 1 comes then count whole 0s below that 1.
1 回表示 (過去 30 日間)
古いコメントを表示
A(:,:,1) =
5 7 8
0 1 9
4 3 6
A(:,:,2) =
1 0 4
3 5 6
9 8 7
2 件のコメント
Stephen23
2017 年 10 月 25 日
What does A have to do with your question? A is not a matrix, and it does not contain only ones and zeros, so it is unclear how it relates to your question.
採用された回答
Stephen23
2017 年 10 月 25 日
編集済み: Stephen23
2017 年 10 月 25 日
>> M = randi(0:1,5,6)
M =
0 1 1 1 0 1
0 1 0 0 0 1
1 0 0 0 1 0
1 1 1 0 0 1
0 0 0 1 1 1
>> sum(cumsum(M,1) & M==0, 1)
ans =
1 2 3 3 1 1
6 件のコメント
Stephen23
2017 年 11 月 7 日
@ntsh kr: read the MATLAB documentation. It is easy to search using any internet search engine. This was the first result returned when I searched for "MATLAB cumsum":
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!