Generating Daily Values using Hourly Values

조회 수: 3 (최근 30일)
Ugur Acar
Ugur Acar 2019년 10월 18일
댓글: Ugur Acar 2019년 10월 18일
i have hourly (8760h) temperature values of each year. I need to generate daily values using hourly values.
For example, i need to calculate some daily parameters like daily average temperature or daily maximum temprerature using hourly data.
Raw data is in a excel file. File format is like this;
After reading excel data, i used 'datenum' function to assign numeric value to each day. Then corrected the first day's numercal value to "1".
for i=1:8760;
raw(i,1)=datenum(Excel_data(i,1),Excel_data(i,2),Excel_data(i,3));
corrected(i,1)=datenum(Excel_data(i,1),Excel_data(i,2),Excel_data(i,3))-raw(1,1)+1;
corrected(i,2)=Excel_data(i,5);
end
Then i have,
corrected=8760x2
After this point, for example, i need calculate daily average temperature for day 1, day 2 ....day 365 at this step.
it needs to look like this;
but i couldnt manage to get a table seems like above.
  댓글 수: 2
Andrei Bobrov
Andrei Bobrov 2019년 10월 18일
here attach your data (your xlsx-file)
Ugur Acar
Ugur Acar 2019년 10월 18일
i attached the data for 5 years.

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 10월 18일
T = readtable('your_xlsx_file.xlsx');
t = datetime([T{:,1:4}, zeros(size(T,1),2)]);
TT = timetable(T{:,end},'RowTimes',t) ;
TT_mean = retime(TT,'daily','mean');
TT_max = retime(TT,'daily','max');
TT_out = [TT_mean,TT_max];
  댓글 수: 1
Ugur Acar
Ugur Acar 2019년 10월 18일
thank you for your suggestion, i didnt know about timetable function, it looks like it will solve the problem, i will try thanks ;)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by