I want to create an average 2d field every 10 timesteps within a 3d matrix (6000 x 100 x100) --> (600 x 100 x100)
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Guillaume
2014-10-14
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));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!