Clear Filters
Clear Filters

QUARTERLY AVERAGE AND VARIANCE from MONTHLY DATA

16 views (last 30 days)
SAPTORSHEE KANTO
SAPTORSHEE KANTO on 13 Sep 2024 at 11:01
Answered: dpb on 13 Sep 2024 at 12:40
I have a dataset of windspeed for each district of INDIA by month for 50 years (only the first seven are displayed below). I want to find the QUARTERLY average and VARIANCE for each district. Any help would be appreciated. Data example below
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str27 state str24 districts float(latitude longitude) byte month float(ws_2023 ws_2022 ws_2021 ws_2020 ws_2019 ws_2018 ws_2017)
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 1 4.589247 3.613052 4.267717 4.635023 4.930599 3.780835 4.673967
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 2 4.079226 4.215449 3.877388 4.538066 3.682131 3.676485 3.948466
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 3 3.171698 2.644508 2.92275 3.351344 3.177872 2.893883 3.182198
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 4 2.689871 2.156992 2.136186 2.872274 2.989198 2.722031 2.906296
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 5 4.14325 5.455741 3.406546 3.855165 3.735876 2.974356 3.366552
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 6 5.78509 4.582315 5.06107 4.991875 5.848218 6.734819 6.140237
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 7 6.180731 4.725333 5.93688 4.066154 5.917521 6.973715 5.876394
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 8 5.776236 5.244017 4.860325 5.294113 7.112219 7.073696 5.248257
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 9 5.926691 4.340836 4.858127 4.631201 4.920815 4.280732 4.387124
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 10 2.832476 4.086142 3.879084 3.524881 2.504806 3.259824 3.722174
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 11 3.89687 3.366515 4.069301 4.236919 3.831769 4.167921 4.207607
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 12 4.377546 4.54319 4.715546 4.315512 4.674977 4.296709 4.937579
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 1 6.210341 4.802261 6.2101 6.206068 6.416927 4.771069 6.214251
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 2 5.469119 5.677119 5.161079 6.119121 5.056155 5.20627 5.359843
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 3 4.022772 3.287575 3.717183 3.603297 3.418595 3.492516 3.59089
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 4 3.014578 2.633554 2.704057 3.562704 3.44037 3.314805 3.605515
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 5 5.758973 7.633964 4.783988 5.456239 5.274939 3.910879 4.607275
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 6 8.273372 6.252726 7.027379 7.017265 8.193433 9.077105 8.145121
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 7 8.684149 7.11254 8.41686 5.523673 7.773966 9.72518 8.343679
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 8 8.257681 7.702024 7.115208 7.253097 9.670324 9.874477 7.653042
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 9 8.256769 6.616227 6.917697 6.731298 6.786049 5.860077 6.402016
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 10 3.68233 4.764365 5.604181 5.805154 3.288253 3.944639 5.052252
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 11 5.013813 4.12091 4.951137 5.162457 5.361066 5.314161 4.652676
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 12 5.805525 6.347145 6.215302 5.600912 6.451589 5.682451 6.354571
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 1 2.071669 1.906998 1.939836 2.075697 2.161556 1.867749 2.186907
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 2 2.252566 2.123164 2.052436 2.442608 2.446047 2.056368 2.235332
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 3 2.232489 2.296364 2.168355 2.435328 2.616105 2.0682 2.37214
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 4 2.163504 2.317636 2.062944 2.230672 2.365663 2.306504 2.151902
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 5 2.233094 2.828299 2.821097 2.442079 2.263708 2.127188 2.934911
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 6 3.514094 2.797159 3.412144 3.196953 3.428785 3.854449 3.74473
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 7 4.419012 3.583243 3.530141 2.285392 3.653605 4.687582 4.112722
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 8 2.849966 3.091185 2.984837 3.136886 3.922278 5.022915 2.880093
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 9 2.927668 2.581071 2.732151 2.731299 2.755776 2.25119 2.190346
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 10 1.935015 2.111777 1.777521 2.475076 1.535323 1.955869 1.695318
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 11 2.019673 2.092834 2.257045 2.613384 2.126691 2.197218 2.132412
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 12 2.483747 2.478249 1.963105 2.345541 2.264333 2.242998 2.073321
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 1 1.987441 1.91066 1.86635 1.984144 1.924251 1.669018 1.983049
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 2 1.724246 1.956904 1.953315 2.075664 1.991458 1.761446 1.777079
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 3 1.760321 1.935036 1.757222 1.722926 1.879776 1.877282 1.911202
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 4 1.681082 2.006113 1.659624 1.749227 1.864686 1.898789 2.223191
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 5 1.778992 2.451346 2.086234 1.976747 2.230505 1.910879 1.914892
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 6 2.416438 2.145792 2.653355 2.153984 2.45271 2.329058 2.48887
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 7 3.393621 3.058341 2.791372 2.005118 2.855509 3.480551 3.17864
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 8 2.665884 2.605833 2.375462 3.258956 3.166419 3.685513 2.249233
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 9 2.15716 2.018571 2.208713 1.722998 2.432045 1.953339 1.662759
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 10 1.6794 1.821005 1.460138 1.546854 1.725753 1.699766 1.331305
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 11 2.362202 1.841369 2.649868 2.37022 1.928938 1.887892 1.993252
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 12 2.372175 2.15403 1.945038 1.970053 2.424489 2.20125 1.92171
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 1 2.011366 2.08107 1.888078 2.175307 2.046566 1.711987 2.04384
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 2 1.931765 2.307734 2.067085 2.44749 2.500002 1.985567 2.09666
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 3 2.373602 2.458717 2.115621 2.740993 2.991105 2.510094 2.925362
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 4 2.548758 2.958261 2.527299 2.988973 3.118593 3.251816 2.894578
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 5 2.386414 3.009452 3.237601 2.876161 3.080603 3.112051 2.889013
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 6 3.161067 3.017374 3.293492 2.636406 3.111402 2.99898 2.789651
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 7 3.664129 3.093009 3.062856 2.255607 3.121134 3.479086 3.147878
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 8 2.84606 2.704954 2.66013 3.023605 3.152747 3.65231 2.367398
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 9 2.383722 2.29152 2.370334 2.238135 2.599038 2.126679 1.888833
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 10 1.867388 1.978476 1.748224 1.915506 1.639327 2.064756 1.631842
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 11 2.148823 1.817687 2.462612 2.304302 1.947004 2.018751 2.124355
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 12 2.385847 2.008522 2.1362 2.018637 2.262868 2.301592 2.08919
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 1 2.016982 2.063248 1.918352 2.203383 1.990902 1.675122 2.033587
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 2 1.856081 2.255 2.059272 2.462871 2.399661 1.932588 1.99705
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 3 2.299871 2.319313 1.99648 2.563258 2.707413 2.299645 2.696358
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 4 2.327566 2.709238 2.341753 2.732137 2.801698 2.962754 2.68071
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 5 2.228699 3.014823 3.060355 2.668153 2.813513 2.880606 2.612157
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 6 3.126399 2.921671 3.138706 2.625664 3.053785 2.862261 2.795511
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 7 3.683172 3.185294 3.050161 2.216544 3.118937 3.509848 3.201589
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 8 2.813833 2.691771 2.644016 3.143722 3.177161 3.748501 2.381069
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 9 2.350031 2.26027 2.358615 2.152197 2.562905 2.069306 1.837807
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 10 1.858355 1.990195 1.677424 1.873514 1.681808 1.952695 1.604742
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 11 2.297016 1.859923 2.603725 2.351421 2.027082 2.004835 2.172207
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 12 2.444685 2.104958 2.152802 2.059896 2.402516 2.272051 2.0992
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 1 2.056532 1.886978 1.878557 2.033217 2.102474 1.978589 2.157366
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 2 2.212771 2.158808 2.061958 2.473369 2.435305 2.272676 2.309306
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 3 2.228094 2.156715 2.145406 2.709743 2.781388 2.305505 2.603585
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 4 2.488699 2.457773 2.239213 2.510946 2.591737 2.673691 2.364792
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 5 2.438172 2.945487 3.199027 2.526551 2.601599 2.514883 2.920263
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 6 3.734309 3.287393 3.806187 3.250664 3.603101 4.160601 3.837503
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 7 4.495672 3.738028 3.756704 2.563712 4.048136 4.704184 3.989675
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 8 3.301626 3.308958 3.112278 3.540206 4.179602 4.823696 2.978726
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 9 3.134211 2.628434 3.065647 2.743994 2.827065 2.477021 2.204995
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 10 2.264361 1.964804 1.912775 2.033182 1.671065 2.17169 1.69776
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 11 2.124653 1.995422 2.382534 2.313824 1.98924 2.006056 2.220546
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 12 2.34654 2.072243 1.885468 2.081381 2.116383 2.190996 2.209795
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 1 2.44496 2.590836 2.425676 2.605971 2.501644 2.515942 2.757463
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 2 2.508425 2.762568 2.567573 3.126446 3.197756 2.60129 2.800029
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 3 3.205389 3.237282 2.953511 3.691676 4.10756 3.36654 4.029366
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 4 3.662039 3.821054 3.530229 3.994833 4.279237 4.280625 4.094285
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 5 3.212586 3.671073 4.05303 3.806825 4.215857 3.95336 3.870458
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 6 3.785578 3.46171 3.949253 3.267265 3.760816 3.631304 3.623147
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 7 4.028875 3.644278 3.422719 2.675529 3.510783 4.426352 3.740652
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 8 3.309439 3.221068 3.280735 2.928878 3.648352 4.515591 3.001187
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 9 3.065851 2.845231 2.899631 2.802588 3.053627 2.959442 2.436929
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 10 2.54024 2.594199 2.424494 2.607889 2.401534 2.679014 2.344
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 11 2.683003 2.720275 3.157192 3.142681 2.674055 2.672804 2.926601
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 12 3.434187 2.877907 2.651093 3.038168 2.910573 2.87581 2.851641
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 1 3.073378 3.212418 2.792619 3.054945 2.819027 2.648022 2.986223
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 2 3.036501 3.030879 3.170356 3.00584 3.223879 2.857637 2.92332
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 3 3.2237 3.786842 3.660542 3.183375 4.176651 4.108239 4.844308
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 4 3.600516 5.530527 4.27437 4.589071 4.829042 5.10582 5.711472
end

Answers (1)

dpb
dpb on 13 Sep 2024 at 12:40
Read the data in with readtimetable and then use retime. It even has <these common calendar timesteps builtin> for you.

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!