Hello, I have a table contains the calendar day of the year and 24-hour frequency. How to get daily max, min, and average temperature from the table?
2 次查看(过去 30 天)
显示 更早的评论
1 个评论
Star Strider
2023-7-11
A relatively straightforward way is to use table2timetable and then retime. The year-month-day information is a bit ambiguous (at least in the sample provided), so you may need to specify it in an options structure created by the detectImportOptions function.
采纳的回答
Voss
2023-7-11
Here's one approach:
% a table similar to yours, with only a few days, and only the relevant columns:
t = table(repelem({'2005-01-01'; '2005-02-01'; '2005-03-01'},96,1),-12.35+0.1*(1:288).','VariableNames',{'DAY','AIR_TEMP_DEG_C'})
% group the DAYs together:
[g, g_id] = findgroups(t.DAY);
% (g_id contains your days, if you should need it:)
g_id
% find the min, max, and mean of AIR_TEMP_DEG_C for each DAY:
[min_all, max_all, mean_all] = splitapply(@get_min_max_mean, t.AIR_TEMP_DEG_C, g)
function [min_val, max_val, mean_val] = get_min_max_mean(in)
min_val = min(in);
max_val = max(in);
mean_val = mean(in);
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!