How to extract monthly data in a matrix

1 ビュー (過去 30 日間)
Stefania Avvedimento
Stefania Avvedimento 2022 年 2 月 14 日
回答済み: Arif Hoq 2022 年 2 月 14 日
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

採用された回答

Arif Hoq
Arif Hoq 2022 年 2 月 14 日
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]
Output = 30×13
1971 34 35 36 37 38 39 40 41 42 43 44 45 1972 46 47 48 49 50 51 52 53 54 55 56 57 1973 58 59 60 61 62 63 64 65 66 67 68 69 1974 70 71 72 73 74 75 76 77 78 79 80 81 1975 82 83 84 85 86 87 88 89 90 91 92 93 1976 94 95 96 97 98 99 100 101 102 103 104 105 1977 106 107 108 109 110 111 112 113 114 115 116 117 1978 118 119 120 121 122 123 124 125 126 127 128 129 1979 130 131 132 133 134 135 136 137 138 139 140 141 1980 142 143 144 145 146 147 148 149 150 151 152 153

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by