I want to create an average 2d field every 10 timesteps within a 3d matrix (6000 x 100 x100) --> (600 x 100 x100)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Michael
el 14 de Oct. de 2014
Comentada: Michael
el 17 de Oct. de 2014
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
0 comentarios
Respuesta aceptada
Guillaume
el 14 de Oct. de 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));
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!