Indexing instances of consecutive zeros

1 view (last 30 days)
Anne D
Anne D on 29 Jun 2015
Answered: Image Analyst on 29 Jun 2015
I have a matrix with columns representing stream gauges and rows representing daily stream flow measurements from 1980-2010. The first column is the year , the second column # month and all other columns are unique gauges. I want to know know when consecutive no-flow days occur, and the duration of those zero flow events for each gauge. I know how to count the number of zeros in a column, but I am new to matlab, so I do not know how to locate and list out consecutive zeros. Any kind of help would be greatly appreciated!

Answers (1)

Image Analyst
Image Analyst on 29 Jun 2015
This is done by the function bwlabel() in the Image Processing Toolbox. Do you have that toolbox? Can you attach a copy of your matrix, like in a .mat file, or a text file with some code to read it in?
Of course each column in your matrix will have an answer that is a different number of events, with each event having a different number of months. So you might need to store the results in a structure array or a cell array or else just have a numerical array big enough to handle all possibilities with some special number if it's not used.

Categories

Find more on Structures 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!