merge 12 rows in 12 matrices to one matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have daily RF data for 55 years and I managed to get mean monthly RF for 55 years for each months seperately. I want to get all mean monthly RF data into one table. How can i do it.
My daily RF data is 365X55
mean for January is 1X55
mean for February is 1X55
Now I need January to December in one table 12X55
Rather than taking one by one mean values for each months, is it easy way to get directly 12X55 matrix?
Please help, Thanks in advance
0 Kommentare
Antworten (1)
Alex Hanes
am 24 Okt. 2022
Bearbeitet: Alex Hanes
am 25 Okt. 2022
I'll define some fake data:
nMonths = 12;
dailyRF = rand(365,55); % fake data array
idxDays = [31; 28; 31; 30; 31; 30; ... % days in each month
31; 31; 30; 31; 30; 31];
idx1 = cumsum(idxDays) + 1 -idxDays; % start index
idx2 = cumsum(idxDays); % end index
avgMonth = zeros(12,55); % pre-allocate
% Loop over the number of months and take average over entire month:
for k = 1:nMonths
avgMonth(k,:) = mean(dailyRF(idx1(k):idx2(k),:),1);
end
Edit: The code is now formatted properly. Original post from my phone.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Tables 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!