How to repeat monthly data over several years?

1 次查看(过去 30 天)
Hello,
I have a potentially simple question.
I have a spatial matrix A=144x192x1x12. The fourth dimension is time in months.
I would like to make a matrix where I have 30 years of repeated data B=144x192x1x360.
I have tried something along the lines of-
for i=1:12;
B(:,:,:,i:12:360)=A(:,:,:,i);
end
But of course this did not work due to differnce sizes of each side.
How would I achieve this simple copying of each year for 30 years?
Thank you,
Holly

采纳的回答

Thiago Henrique Gomes Lobato
Matlab has a function for concatenating values in different dimensions, you could solve your problem like this:
A = randn(144,192,1,12);
B = [];
for i=1:30
B = cat(4,B,A);
end
size(B)
ans =
144 192 1 360

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by