How to separate and order timetable data by year
6 ビュー (過去 30 日間)
古いコメントを表示
data = readtable('USA_SITE_004_final.txt'); %import text file and present as table
data_nan = standardizeMissing(data, -999); %return '-999' values as 'NaN'
hourly_temp_rain_sm = data_nan(:, [1 5 11 26]); %extract key variables
TT = table2timetable(hourly_temp_rain_sm); %form timetable
daily_temp_rain_sm = retime(TT, 'daily', 'mean'); %retime data to obtain daily averages
daily_sm = daily_temp_rain_sm(:,3);
Hi, i have created a timetable and retimed soil moisture data here to obtain daily averages for a period of several years. I now want to be able to obtain a metric for each year and to do this i will need to separate the data into years, keeping the daily averages each year. I hope that makes sense and thank you in advance for any help.
0 件のコメント
回答 (1 件)
Adam Danz
2021 年 11 月 15 日
編集済み: Adam Danz
2021 年 11 月 15 日
> I now want to be able to obtain a metric for each year and to do this i will need to separate the data into years, keeping the daily averages each year.
You can use retime with yearly intervals. By storing this in a different variable, you can also keep the daily values.
dt = datetime(1999,1,1) + days(0:1:2000)';
rainfall = rand(numel(dt),1);
TT = timetable(dt, rainfall) % Daily rainfall
yearlyTT = retime(TT,'yearly','mean') % yearly avg
Note that the aggregate method can be a function handle if your metric is not a built-in option. See doc retime for more info.
6 件のコメント
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!