How can I find index from a 3D matrix?

2 visualizaciones (últimos 30 días)
Ashfaq Ahmed
Ashfaq Ahmed el 21 de Feb. de 2023
Comentada: Ashfaq Ahmed el 21 de Feb. de 2023
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?

Respuesta aceptada

Matt J
Matt J el 21 de Feb. de 2023
Editada: Matt J el 21 de Feb. de 2023
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 comentarios
Ashfaq Ahmed
Ashfaq Ahmed el 21 de Feb. de 2023
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 el 21 de Feb. de 2023
Got it, I guess it should be mean(Md,3)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by