Daily mean through long time
21 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Star Strider
circa 11 ore fa
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')
.
2 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Dates and Time in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!