Calculating flow sessions from a water meter time series

1 view (last 30 days)
Pardon me if this question is too trivial, but I am just learning MatLab and trying to learn more about the elegance of the language. I know how to do a Fortran-style solve of this problem, but I thought I'd ask folks for a more Matlab-like solution.
I have two variables holding the flow rate of a water meter every 15 minutes: time and data.
The meter shows zero for long periods, then ramps up to show a flow session(say, watering my trees), then goes back to zero after the session is done. Is there a simple way to detect a session (a flow between two zero flows) and then add up the sum of flows during the session? (say, calculating how long and how many gallons flowed to the trees.)

Answers (1)

dpb
dpb on 29 Aug 2015
OK, since this is a self-described learning exercise, hints first (treat it kinda' like homework with "show your work first") instead of a direct solution.
First, your two data files didn't get attached; try again if want somebody to actually see the data.
Second, look at the File Exchange submittal contiguous
Third, with it in mind, what could you see doing with the results from it if the data were turned into a logic array first of
flowOn=data>0; % ? (A logical array where there is non-zero flow observed)
Lastly, then look at
doc cumsum % and friends making use of the previous steps.
At this point you would still likely make use of a loop to accumulate each different flow period; however, more advanced and with some effort you should be able to eliminate that loop--
doc accumarray % would be one likely candidate there...
See if that gets you going... :)

Categories

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