How to get hourly mean values for each table ?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have table with several variables. I want to count mean values/hour and day/24h.Insert it into same table to new collumns.
'1. 9. 2014 0:10:00' 17.5888824462890 16.6006196022034 9.24703636169433 7.35358324050903 0
'1. 9. 2014 0:20:00' 17.4715484619140 16.3727707386017 9.08979740142822 7.28297333717346 0
'1. 9. 2014 0:30:00' 17.2833709716796 16.4321424484253 9.07513818740844 7.35700426101684 0
'1. 9. 2014 0:40:00' 17.0890960693359 16.5259598731994 9.30411930084228 7.22184057235717 0
'1. 9. 2014 0:50:00' 16.9373931884765 16.1714633464813 8.95496788024902 7.21649546623230 0
'1. 9. 2014 1:00:00' 16.6564178466796 16.2206918239593 8.83789930343627 7.38279252052307 0
'1. 9. 2014 1:10:00' 16.5172119140625 16.1632557392120 8.75078907012939 7.41246666908264 0
'1. 9. 2014 1:20:00' 16.4233245849609 16.3327004909515 8.99931888580322 7.33338160514831 0
'1. 9. 2014 1:30:00' 16.2860870361328 16.1293127059936 8.95226049423217 7.17705221176147 0
'1. 9. 2014 1:40:00' 16.2329864501953 16.1379649639130 9.00060062408447 7.13736433982849 0
'1. 9. 2014 1:50:00' 16.2068939208984 16.2174114704132 9.01585254669189 7.20155892372131 0
'1. 9. 2014 2:00:00' 16.1468353271484 16.2643773555756 9.07311763763427 7.19125971794128 0
'1. 9. 2014 2:10:00' 16.1303100585937 15.9934119701385 8.88413515090942 7.10927681922912 0
'1. 9. 2014 2:20:00' 16.0941467285156 15.8957414627075 8.74294996261596 7.15279150009155 0
'1. 9. 2014 2:30:00' 15.9051818847656 16.0573853679001 8.89083251953125 7.12535409927368 0.0411987490952014
'1. 9. 2014 2:40:00' 15.8107452392578 16.0739471983164 8.88998212814331 7.15993247032165 0.0240325998514890
column1=date
column2=temp
column3=total
column4=s
column5=j
column6=v
I want to create a table where in column7 will be hourly mean for column2(temp),column8(total),column9(s),column10(j),column(11)=v
raw.Properties.VariableNames{1} = 'date'; %datetime format
raw.Properties.VariableNames{2} = 'tem'; %double
raw.Properties.VariableNames{3} = 'sum'; %double
raw.Properties.VariableNames{4} = 's'; %double
raw.Properties.VariableNames{5} = 'j'; %double
raw.Properties.VariableNames{6} = 'v'; %double
2 Commenti
Guillaume
il 21 Mar 2019
What is the actual type of the first variable (the date) of your table. Is it actually a 2D char array or cell vector of char vectors as your example would imply or is it actually a column vector of datetime?
class(yourtable.(1));
What are the variables names of your table?
All this can easily be answered if you attach your data as a mat file or use valid matlab syntax for your example.
Risposte (1)
Peter Perkins
il 22 Mar 2019
Matthew, I really can't tell what you are asking for, you need to give a short, clear example.
retime on a timetable may be what you want:
>> tt = table2timetable(raw);
>> head(tt)
ans =
8×5 timetable
date temp sum s j v
__________________ ______ ______ ______ ______ _
1. 9. 2014 0:10:00 17.589 16.601 9.247 7.3536 0
1. 9. 2014 0:20:00 17.472 16.373 9.0898 7.283 0
1. 9. 2014 0:30:00 17.283 16.432 9.0751 7.357 0
1. 9. 2014 0:40:00 17.089 16.526 9.3041 7.2218 0
1. 9. 2014 0:50:00 16.937 16.171 8.955 7.2165 0
1. 9. 2014 1:00:00 16.656 16.221 8.8379 7.3828 0
1. 9. 2014 1:10:00 16.517 16.163 8.7508 7.4125 0
1. 9. 2014 1:20:00 16.423 16.333 8.9993 7.3334 0
>> tthourly = retime(tt,'hourly','mean');
>> head(tthourly)
ans =
8×5 timetable
date temp sum s j v
__________________ ______ ______ ______ ______ _________
1. 9. 2014 0:00:00 17.274 16.421 9.1342 7.2864 0
1. 9. 2014 1:00:00 16.387 16.2 8.9261 7.2741 0
1. 9. 2014 2:00:00 15.974 16.034 8.8796 7.1434 0.010872
1. 9. 2014 3:00:00 15.263 16.394 8.7914 7.6027 0
1. 9. 2014 4:00:00 15.073 20.812 10.545 10.267 0
1. 9. 2014 5:00:00 15.072 20.649 11.025 9.6183 0.0054042
1. 9. 2014 6:00:00 15.073 20.543 11.126 9.4139 0.0035604
1. 9. 2014 7:00:00 15.074 20.689 10.987 9.7022 0
4 Commenti
Peter Perkins
il 2 Apr 2019
Since neither 17.655 nor 9.574 appear anywhere in tyour example output of tthourly, it's impossible to know where they came from. I*t looks like maybe you want to do some kind of join operation after retiming.
Vedere anche
Categorie
Scopri di più su Timetables 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!