How to detect number of zero string in a cell
Show older comments
Hi,I attached my matlab code and database. I want to count howmany '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0' happens in diffr
Accepted Answer
More Answers (1)
Image Analyst
on 18 Jan 2016
Edited: Image Analyst
on 18 Jan 2016
Anyway, to count the number of zeros in a line of text from your file, you can do this to one line of text
numZeros = sum(textLine == '0');
To count the number of contiguous regions of zeros (so like [0 0 0 0] would be one region instead of 4), you'd use bwlabel():
[L, numZeroRegions] = bwlabel(textLine == '0');
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!