How to calculate the hourly average
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I should calculate an hourly average of this file.
This is the start of my script:
clear all
Func=importdata('Matlab.csv');
data_num=Funcdata;
data_str=Func.textdata;
data_str_splitted=split(data_str);
for i=1:length(data_str_splitted)
days_code(i,:)=str2double(erase(data_str_splitted(i,1),"/"));
end
Could anyone give me an advice?
Thank you.
2 Kommentare
Rik
am 26 Jan. 2021
Why don't you first start looking for a way to import your data that makes use of Matlab data types? Have you looked for a function that will read csv files?
It is good to try to write things yourself, but especially when you start using Matlab you should try to see what tools Matlab provides you with.
Akzeptierte Antwort
Star Strider
am 26 Jan. 2021
If you have R2016b or later, this is straightforward:
T1 = readtable('Matlab.csv');
First_5_Rows = T1(1:5,:);
TT1 = table2timetable(T1);
TT1 = retime(TT1, 'hourly','mean');
First_10_Rows = TT1(1:10,:)
producing:
First_10_Rows =
10×3 timetable
Var1 Var2 Var3 Var4
___________________ _______ ______ ______
06/23/2015 01:00:00 -30.195 71.304 159.62
06/23/2015 02:00:00 -30.239 71.288 159.57
06/23/2015 03:00:00 -29.93 71.46 158.83
06/23/2015 04:00:00 -29.922 71.487 157.72
06/23/2015 05:00:00 -29.35 71.939 155.11
06/23/2015 06:00:00 -28.742 72.334 156.36
06/23/2015 07:00:00 -28.336 72.619 158.46
06/23/2015 08:00:00 -28.339 72.436 158.91
06/23/2015 09:00:00 -27.784 72.907 157.82
06/23/2015 10:00:00 -27.128 73.226 153.73
.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!