Number of zeros in a matrix
显示 更早的评论
I need to create a function where I have a matrix and the function returns the number of zeros in that matrix. I need to do this using the if condition.
Then write in a .txt file which columns had more than 12 zeros.
Can someone help me out with this?
Thank you very much.
采纳的回答
更多回答(2 个)
Andrei Bobrov
2012-11-17
a - your matrix
number_columns = find(sum(~a) > 12);
Walter Roberson
2012-11-18
numel(M) - nnz(M)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!