How to extract monthly data in a matrix
    4 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Stefania Avvedimento
 le 14 Fév 2022
  
    
    
    
    
    Réponse apportée : Jasmine
 le 25 Mar 2025
            Dear all,
I have a matrix of monthly precipitation values for a period of 30 years, from 1971 to 2000 (see Fig. 1 attached).
I would like to extract for each month the values of precipitation of all the years considered, as shown in Fig. 2 (I did it manually). Since I have to repeat this procedure for several climate models, could you please give me any suggestion on how to automatize the extraction?
BR,
Stefania
0 commentaires
Réponse acceptée
  Arif Hoq
      
 le 14 Fév 2022
        As you did not attach any data, i took the random data
A=readtable('Data.xlsx');
Data=table2array(A(:,2));
Year=(1971:2000)';
N=length(Data);
C=cell(N/30,1);
for i=1:12:N
    C{i}=Data(i:i+11);
end
Matrix=[C{:}]';
Output=[Year Matrix]
0 commentaires
Plus de réponses (2)
  Jasmine
 le 25 Mar 2025
        % Extract Monthly Rainfall
monthlyRainfall = accumarray([data.YEAR, data.MONTH], data.RAINFALL, [RAINFALL], @sum);
0 commentaires
  Jasmine
 le 25 Mar 2025
        % Extract Monthly Rainfall
monthlyRainfall = accumarray([data.YEAR, data.MONTH], data.RAINFALL, [RAINFALL], @sum);
0 commentaires
Voir également
Catégories
				En savoir plus sur Climate Science and Analysis dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


