Note that there are some explanatory texts on larger screens.

plurals
  1. POMATLAB: n-minute/hour/day averages of a time-series
    primarykey
    data
    text
    <p>This is a follow-up to an earlier question of mine posted <a href="https://stackoverflow.com/questions/17032033/matlab-averaging-time-series-data-without-loops">here</a>. Based on Oleg Komarov's answer I wrote a little tool to get daily, hourly, etc. averages or sums of my data that uses accumarray() and datevec()'s output structure. Feel free to have a look at it <a href="http://pastebin.com/gkTyShZM" rel="nofollow noreferrer">here</a> (it's probably not written very well, but it works for me).</p> <p>What I would like to do now is add the functionality to calculate n-minute, n-hour, n-day, etc. statistics instead of 1-minute, 1-hour, 1-day, etc. like my function does. I have a rough idea that simply loops over my time-vector t (which would be pretty much what I would have done already if I hadn't learnt about the beautiful accumarray()), but that means I have to do a lot of error-checking for data gaps, uneven sampling times, etc.</p> <p>I wonder if there is a more elegant/efficient approach that lets me re-use/extend my old function posted above, i.e. something that still makes use of accumarray() and datevec(), since this makes working with gaps very easy.</p> <p>You can download some sample data taken from my last question <a href="https://dl.dropboxusercontent.com/u/9437411/sampledata_ts.mat" rel="nofollow noreferrer">here</a>. These were sampled at 30 min intervals, so a possible example of what I want to do would be to calculate 6 hour averages <em>without</em> relying on the assumption that they are free of gaps and/or always sampled at exactly 30 min.</p> <hr> <p>This is what I have come up with so far, which works reasonably well, apart from a small but easily fixed problem with the time stamps (e.g. 0:30 is representative for the interval from 0:30 to 0:45 -- my old function suffers from the same problem, though):</p> <p>[ ... see my answer below ...]</p> <p>Thanks to <a href="https://stackoverflow.com/questions/2323031/matlab-compute-mean-of-each-1-minute-interval-of-a-time-series">woodchips</a> for inspiration.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload