Calculating flow sessions from a water meter time series
2 次查看(过去 30 天)
显示 更早的评论
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.
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.)
0 个评论
回答(1 个)
dpb
2015-8-29
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.
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... :)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!