Looks like you use excel macros, not VBA. In any case, no you should not do the same method at all in matlab. Matlab is a lot more powerful but requires a different way of thinking.
Giving us a file we can play with would have been more useful than screenshots. Anyway, first thing you need to do is import your data in matlab. For that use readtable with appropriate options (possibly none). Something like: flowtable = readtable('c:\somewhere\somefile.xlsx');
If necessary rename the columns of the table to something useful. In the following I assume the flow column is called Flow. You can then detect dry periods, their beginnings and ends:
dryperiod = flowtable.Flow == 0;
transitions = diff([false, dryperiod, false]);
drystarts = find(transitions == 1);
dryends = find(transitions == -1) - 1;
You can then build your result table. I'm assuming that your flowtable has a single column named DateTime of type datetime drytable = table(flowtable.DateTime(drystarts), ...
flowtable.DateTime(dryends), ...
flowtable.DateTime(dryends) - flowtable.DateTime(drystarts), ...
'VariableNames', {'Start', 'End', 'Duration'})
Best Answer