merge 12 rows in 12 matrices to one matrix
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Alex Hanes
el 24 de Oct. de 2022
Editada: Alex Hanes
el 25 de Oct. de 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 comentarios
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!