Azzera filtri
Azzera filtri

How can I find index from a 3D matrix?

2 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Matt J
Matt J il 21 Feb 2023
Modificato: Matt J il 21 Feb 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 Commenti
Ashfaq Ahmed
Ashfaq Ahmed il 21 Feb 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 il 21 Feb 2023
Got it, I guess it should be mean(Md,3)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by