How to get average of data using different time range?
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Descriptive Statistics and Insights en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!