Effacer les filtres
Effacer les filtres

I want to create an average 2d field every 10 timesteps within a 3d matrix (6000 x 100 x100) --> (600 x 100 x100)

1 vue (au cours des 30 derniers jours)
I have for example a 3d matrix like (6000 x 100 x 100) with the first array being time, or the vector I want to average. How can I create an average every 10 days so that I am left with 600 x 100 x 100, so that 10 timesteps have been averaged to produce one 2d field matrix.
I have tried using accumarray but I can't seem to get it to work...and I have tried the following code (after permuting matrix):
for x = 1:100; x for y = 1:100;
aa = squeeze(data(x,y,:));
test(x,y) = nanmean(aa(1:10:end));
end
end
but then I am not sure what to do next...
Can someone help me?
thanks, Michael

Réponse acceptée

Guillaume
Guillaume le 14 Oct 2014
Reshape your matrix into a 3d array of size 10x600x100x100 and calculate the average of that along the first dimension:
tdata = reshape(data, 10, 600, 100, 100);
mdata = squeeze(mean(tdata));

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by