How to get average of data using different time range?
이전 댓글 표시
Hello,
I have to get average data with different time range.
'Temp_table' data is not linear, but step data.
For exapmle, like this :
Temperature = randi([-20 40], 24*365, 1); % 365 days data corresponding for 1 hours
Temp_table = timetable(Temperature, 'TimeStep', hours);
And, I have range of time with different interval :
T(1, :) = [seconds(1), seconds(82190)]; % start, end point of time
T(2, :) = [seconds(82191), seconds(101972)];
...
For example, I have to get average T(1) temperature.
I have tried this, but as the time to calculate increases, the calculation speed seems to slow down.
Time_ranges = arrayfun(@(t1, t2) timerange(t1, t2, 'closed'), T(:, 1), T(:, 2), 'un', 0);
Temp_avg = cellfun(@(x) mean(Temp_table(x, 'Temp').Variables), Time_ranges);
Is there a simpler or easier way?
Thanks in advance.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Descriptive Statistics and Insights에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!