- Dates and Time - https://in.mathworks.com/help/matlab/date-and-time-operations.html
- datetime - https://in.mathworks.com/help/matlab/ref/datetime.html
- timetable - https://in.mathworks.com/help/matlab/ref/timetable.html
- retime - https://in.mathworks.com/help/matlab/ref/timetable.retime.html
- standardizeMissing - https://in.mathworks.com/help/matlab/ref/standardizemissing.html
- rmmissing - https://in.mathworks.com/help/matlab/ref/rmmissing.html
I have timestamp_start and end data with other variables at the interval of 30 min yearly data. How can I sum/ avg daily/monthly/yearly avoiding -9999/Nan ?
1 次查看(过去 30 天)
显示 更早的评论
201901010000 201901010030 -9999 -9999 -9999 -9999 -9999
201901010030 201901010100 -9999 -9999 -9999 -9999 -9999
201901010100 201901010130 -9999 -9999 -9999 -9999 -9999
201901010130 201901010200 -9999 -9999 -9999 -9999 -9999
201901010200 201901010230 -9999 -9999 -9999 -9999 -9999
201901010230 201901010300 -9999 -9999 -9999 -9999 -9999
201901010300 201901010330 -9999 -9999 -9999 -9999 -9999
201901010330 201901010400 -9999 -9999 -9999 -9999 -9999
201901010400 201901010430 -9999 -9999 -9999 -9999 -9999
201901010430 201901010500 -9999 -9999 -9999 -9999 -9999
201901010500 201901010530 -9999 -9999 -9999 -9999 -9999
201901010530 201901010600 -9999 -9999 -9999 -9999 -9999
201901010600 201901010630 -9999 -9999 -9999 -9999 -9999
201901010630 201901010700 -9999 -9999 -9999 -9999 -9999
201901010700 201901010730 -9999 -9999 -9999 -9999 -9999
201901010730 201901010800 -9999 -9999 -9999 -9999 -9999
201901010800 201901010830 -9999 -9999 -9999 -9999 -9999
201901010830 201901010900 -9999 -9999 -9999 -9999 -9999
201901010900 201901010930 -9999 -9999 -9999 -9999 -9999
201901010930 201901011000 -9999 -9999 -9999 -9999 -9999
201901011000 201901011030 215 9.1 2427.7 -9999 -10.6
201901011030 201901011100 130 9.6 2314.4 1.85 -11.3
201901011100 201901011130 165 9.0 2231.5 0.6 -32.6
201901011130 201901011200 421 7.7 2261.6 1.2 -12.6
201901011200 201901011230 421 7.5 2279.4 1.7 2.3
201901011230 201901011300 201 7.1 2258.2 4.1 2.1
201901011300 201901011330 105 6.9 2255.8 4.4 27.0
201901011330 201901011400 519 6.9 2259.5 3.9 10.1
0 个评论
回答(1 个)
Seth Furman
2022-9-12
编辑:Seth Furman
2022-9-12
Take a look at the following:
data = [
201901010000 201901010030 -9999 -9999 -9999 -9999 -9999
201901010030 201901010100 -9999 -9999 -9999 -9999 -9999
201901010100 201901010130 -9999 -9999 -9999 -9999 -9999
201901010130 201901010200 -9999 -9999 -9999 -9999 -9999
201901010200 201901010230 -9999 -9999 -9999 -9999 -9999
201901010230 201901010300 -9999 -9999 -9999 -9999 -9999
201901010300 201901010330 -9999 -9999 -9999 -9999 -9999
201901010330 201901010400 -9999 -9999 -9999 -9999 -9999
201901010400 201901010430 -9999 -9999 -9999 -9999 -9999
201901010430 201901010500 -9999 -9999 -9999 -9999 -9999
201901010500 201901010530 -9999 -9999 -9999 -9999 -9999
201901010530 201901010600 -9999 -9999 -9999 -9999 -9999
201901010600 201901010630 -9999 -9999 -9999 -9999 -9999
201901010630 201901010700 -9999 -9999 -9999 -9999 -9999
201901010700 201901010730 -9999 -9999 -9999 -9999 -9999
201901010730 201901010800 -9999 -9999 -9999 -9999 -9999
201901010800 201901010830 -9999 -9999 -9999 -9999 -9999
201901010830 201901010900 -9999 -9999 -9999 -9999 -9999
201901010900 201901010930 -9999 -9999 -9999 -9999 -9999
201901010930 201901011000 -9999 -9999 -9999 -9999 -9999
201901011000 201901011030 215 9.1 2427.7 -9999 -10.6
201901011030 201901011100 130 9.6 2314.4 1.85 -11.3
201901011100 201901011130 165 9.0 2231.5 0.6 -32.6
201901011130 201901011200 421 7.7 2261.6 1.2 -12.6
201901011200 201901011230 421 7.5 2279.4 1.7 2.3
201901011230 201901011300 201 7.1 2258.2 4.1 2.1
201901011300 201901011330 105 6.9 2255.8 4.4 27.0
201901011330 201901011400 519 6.9 2259.5 3.9 10.1
];
t = array2table(data);
t.Properties.VariableNames(1:2) = ["Start","End"]
t.Start = datetime(string(t.Start),InputFormat="yyyyMMddHHmm")
t.End = datetime(string(t.End),InputFormat="yyyyMMddHHmm")
t = standardizeMissing(t,-9999,"DataVariables",t.Properties.VariableNames(3:end))
tNoMissing = rmmissing(t,"DataVariables",t.Properties.VariableNames(3:end));
tNoMissing = table2timetable(tNoMissing)
retime(tNoMissing(:,3:end),"daily","mean")
retime(tNoMissing(:,3:end),"monthly","sum")
retime(tNoMissing(:,3:end),"yearly","mean")
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!