Averaging data every three hours
Mostra commenti meno recenti
Hi everyone!
I have been looking for one solution for this issue but with no results.
From the next data set:
YEAR MONTH DAY HOUR MINUTE SECOND WIND DIRECTION (DEGREES)
2009 1 1 0 0 0 20
2009 1 1 0 10 0 21
2009 1 1 0 20 0 24
2009 1 1 0 30 0 29
2009 1 1 0 40 0 30
2009 1 1 0 50 0 28
2009 1 1 1 0 0 24
2009 1 1 1 10 0 31
2009 1 1 1 20 0 27
2009 1 1 1 30 0 25
2009 1 1 1 40 0 29
2009 1 1 1 50 0 31
2009 1 1 2 0 0 30
2009 1 1 2 10 0 30
2009 1 1 2 20 0 25
2009 1 1 2 30 0 27
2009 1 1 2 40 0 18
2009 1 1 2 50 0 27
2009 1 1 3 0 0 27
2009 1 1 3 10 0 29
2009 1 1 3 20 0 29
2009 1 1 3 30 0 30
2009 1 1 3 40 0 30
2009 1 1 3 50 0 30
2009 1 1 4 0 0 34
2009 1 1 4 10 0 38
2009 1 1 4 20 0 43
2009 1 1 4 30 0 57
2009 1 1 4 40 0 79
2009 1 1 4 50 0 72
2009 1 1 5 0 0 65
2009 1 1 5 10 0 64
2009 1 1 5 20 0 59
2009 1 1 5 30 0 56
2009 1 1 5 40 0 51
2009 1 1 5 50 0 51
2009 1 1 6 0 0 67
2009 1 1 6 10 0 60
2009 1 1 6 20 0 61
2009 1 1 6 30 0 78
2009 1 1 6 40 0 82
2009 1 1 6 50 0 88
2009 1 1 7 0 0 87
2009 1 1 7 10 0 85
2009 1 1 7 20 0 96
2009 1 1 7 30 0 92
2009 1 1 7 40 0 99
2009 1 1 7 50 0 108
2009 1 1 8 0 0 123
2009 1 1 8 10 0 118
2009 1 1 8 20 0 101
2009 1 1 8 30 0 99
2009 1 1 8 40 0 108
2009 1 1 8 50 0 105
2009 1 1 9 0 0 104
2009 1 1 9 10 0 105
2009 1 1 9 20 0 101
2009 1 1 9 30 0 95
2009 1 1 9 40 0 96
2009 1 1 9 50 0 101
2009 1 1 10 0 0 96
2009 1 1 10 10 0 113
2009 1 1 10 20 0 126
2009 1 1 10 30 0 107
2009 1 1 10 40 0 105
2009 1 1 10 50 0 88
2009 1 1 11 0 0 86
2009 1 1 11 10 0 72
2009 1 1 11 20 0 72
2009 1 1 11 30 0 70
2009 1 1 11 40 0 79
2009 1 1 11 50 0 81
2009 1 1 12 0 0 90
2009 1 1 12 10 0 101
2009 1 1 12 20 0 106
2009 1 1 12 30 0 100
2009 1 1 12 40 0 102
2009 1 1 12 50 0 93
2009 1 1 13 0 0 96
2009 1 1 13 10 0 91
2009 1 1 13 20 0 97
2009 1 1 13 30 0 100
2009 1 1 13 40 0 94
2009 1 1 13 50 0 101
2009 1 1 14 0 0 86
2009 1 1 14 10 0 86
2009 1 1 14 20 0 88
2009 1 1 14 30 0 87
2009 1 1 14 40 0 93
2009 1 1 14 50 0 98
2009 1 1 15 0 0 92
2009 1 1 15 10 0 92
2009 1 1 15 20 0 79
2009 1 1 15 30 0 79
2009 1 1 15 40 0 85
2009 1 1 15 50 0 89
2009 1 1 16 0 0 95
2009 1 1 16 10 0 84
2009 1 1 16 20 0 79
2009 1 1 16 30 0 75
2009 1 1 16 40 0 86
2009 1 1 16 50 0 79
2009 1 1 17 0 0 97
2009 1 1 17 10 0 84
2009 1 1 17 20 0 67
2009 1 1 17 30 0 72
2009 1 1 17 40 0 80
2009 1 1 17 50 0 89
2009 1 1 18 0 0 106
2009 1 1 18 10 0 21
2009 1 1 18 20 0 29
2009 1 1 18 30 0 320
2009 1 1 18 40 0 315
2009 1 1 18 50 0 319
2009 1 1 19 0 0 325
2009 1 1 19 10 0 323
2009 1 1 19 20 0 330
2009 1 1 19 30 0 332
2009 1 1 19 40 0 325
2009 1 1 19 50 0 328
2009 1 1 20 0 0 330
2009 1 1 20 10 0 328
2009 1 1 20 20 0 333
2009 1 1 20 30 0 331
2009 1 1 20 40 0 341
2009 1 1 20 50 0 338
2009 1 1 21 0 0 340
2009 1 1 21 10 0 341
2009 1 1 21 20 0 350
2009 1 1 21 30 0 348
2009 1 1 21 40 0 354
2009 1 1 21 50 0 350
2009 1 1 22 0 0 358
2009 1 1 22 10 0 353
2009 1 1 22 20 0 359
2009 1 1 22 30 0 354
2009 1 1 22 40 0 2
2009 1 1 22 50 0 8
2009 1 1 23 0 0 3
2009 1 1 23 10 0 14
2009 1 1 23 20 0 13
2009 1 1 23 30 0 15
2009 1 1 23 40 0 20
2009 1 1 23 50 0 17
2009 1 2 0 0 0 25
It is necessary an average of data (wind speed) exactly every three hours
The results desired after the application of the filter are the next:
YEAR MONTH DAY HOUR MINUTE SECOND Wind speed (average three hours)
2009 1 1 3 0 0 26.47
2009 1 1 6 0 0 49.11
2009 1 1 9 0 0 94.11
2009 1 1 12 0 0 93.50
2009 1 1 15 0 0 95.06
2009 1 1 18 0 0 84.28
2009 1 1 21 0 0 294.89
2009 1 2 0 0 0 182.44
Best regards
Risposta accettata
Più risposte (1)
dpb
il 21 Feb 2017
Use Matlab internal storage order to do this over regularly-fixed data...
>> wdir=importdata('luis.txt'); % the data array
>> mean(reshape(wdir(1:end-1,end),18,[])).'
ans =
26.4444
46.8889
92.0556
94.2778
94.9444
83.5000
281.8889
199.9444
>>
This doesn't quite match your numeric value(s); I can get the first value above if I include the 0-hour of the next day in the first average but can't reproduce the rest; not sure what you did...
>> mean(wdir(1:19,end)) % this matches but last point is 0 hr of day 3, _not_ day 2
ans =
26.4737
>> mean(wdir(18+(1:19),end)) % did average from 19th point??? Apparently not...
ans =
47.9474
>> mean(wdir(18:36,end)) % well, 19 points from 18th??? nope, not that, either
ans =
45.8421
>>
So, don't know where the others came from after the first, but I think the correct answer should be that given above.
NB: The column header is "Wind Direction" not "Wind Speed" and the numbers pretty-much indicate it has to be that...might want to fix up your output title to match.
Categorie
Scopri di più su Time-Frequency Analysis in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!