I want to create an average 2d field every 10 timesteps within a 3d matrix (6000 x 100 x100) --> (600 x 100 x100)
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Guillaume
on 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));
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!