Effacer les filtres
Effacer les filtres

How can I find index from a 3D matrix?

2 vues (au cours des 30 derniers jours)
Ashfaq Ahmed
Ashfaq Ahmed le 21 Fév 2023
Commenté : Ashfaq Ahmed le 21 Fév 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?

Réponse acceptée

Matt J
Matt J le 21 Fév 2023
Modifié(e) : Matt J le 21 Fév 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 commentaires
Ashfaq Ahmed
Ashfaq Ahmed le 21 Fév 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 le 21 Fév 2023
Got it, I guess it should be mean(Md,3)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by