How can I find index from a 3D matrix?

3 次查看(过去 30 天)
Hi, I have a matrix M that is of this size: M = 376x268x764 double.
Here, 376x268 are latitude longitude grid cells and 764 is the day counts.
Now, from that 764 days, I want to precicely select these 16 days -
d = [1, 3, 45, 56, 111, 121, 135, 440, 489, 491, 511, 555, 569, 599, 608, 700];
in a way that, I still have a 3D matrix but the new size is 376x268x16
Can anyone please help me doing this?

采纳的回答

Matt J
Matt J 2023-2-21
编辑:Matt J 2023-2-21
M=rand(376,268,764);
d = [1, 3, 45, 56, 111, 121, 135, 440, 489, 491, 511, 555, 569, 599, 608, 700];
Md=M(:,:,d);
whos M Md
Name Size Bytes Class Attributes M 376x268x764 615894016 double Md 376x268x16 12898304 double
  2 个评论
Ashfaq Ahmed
Ashfaq Ahmed 2023-2-21
Hi @Matt J, thanks! Yes, that was exactly what I wanted. Can you please tell me how can I average the values for the lat/lon grid for all these 16 arrays so that I have the Averaged_Md of size 376x268x1?
Ashfaq Ahmed
Ashfaq Ahmed 2023-2-21
Got it, I guess it should be mean(Md,3)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by