merge 12 rows in 12 matrices to one matrix
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Alex Hanes
il 24 Ott 2022
Modificato: Alex Hanes
il 25 Ott 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 Commenti
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices 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!