Daily mean through long time
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi All
The variable, the year, the month, the day, the hour, and the minutes are all in a data file.
i need to find a loop that can find out the variable's daily average.
Pay attention to the point that the variable has 24 values during the day. This means that it changes every hour.
Please help me create a loop so that I can find the average daily value for the month and year.
댓글 수: 0
채택된 답변
Star Strider
2024년 12월 21일
T1 = readtable('data.xls') % Import Data
DateTime = datetime([T1{:,1:5} zeros(size(T1,1),1)]); % Create ‘datetime’ Array From Available Data & Add ‘zeros’ Vector Of Seconds
T1 = removevars(T1, 1:5); % Remove Original Datee & Time Data
T1 = addvars(T1, DateTime, Before=1) % Add New ‘datetime’ Array
TT1 = table2timetable(T1); % Converet To ‘timetable’
TT1 = retime(TT1, 'daily', 'mean') % Calculate & Show Results
[t1,t2] = bounds(T1.DateTime(T1.avs >= 5))
figure
plot(T1.DateTime, T1.avs, DisplayName='Original Data')
hold on
stairs(TT1.DateTime, TT1.avs, DisplayName='Daily Mean', LineWidth=2)
hold off
grid
xlim([t1 t2]+[-1 1]*days(3))
xlabel('Time')
ylabel('avs')
legend(Location='SW')
.
추가 답변 (1개)
참고 항목
카테고리
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!