MATLAB: Averaging time-series data without loops?

后端 未结 1 1467
小蘑菇
小蘑菇 2020-12-21 07:32

I have measured a handful of variables in 30 minute intervals. Time stamps are available in datevec or datenum format. I want to calculate ...

相关标签:
1条回答
  • 2020-12-21 08:31

    Considering that datevec() output is stored in tvec and data in x, group with unique(...,'rows') and accumulate with accumarray():

    % Group by day
    [unDates, ~, subs] = unique(tvec(:,1:3),'rows');
    
    % Accumulate by day
    [unDates accumarray(subs, x, [], @mean)]
    
    % Similarly by hour
    [unHours, ~, subs] = unique(tvec(:,4:5),'rows');
    [unHours accumarray(subs, x, [], @mean)]
    
    0 讨论(0)
提交回复
热议问题