Effacer les filtres
Effacer les filtres

How to calculate the mean along a matrix dimension, but using a variable range, without using a loop?

1 vue (au cours des 30 derniers jours)
I have a matrix A of dimensions (i=80,j=50,k=40,t=12), where the first two dimensions represent longitude and latitude, the third, depth, and the fourth, time. I also have an integer vector v of size 1x12. How can I obtain a matrix of size (80,50,12), by averaging A along its third dimension, but for each t, the range used to compute the mean is given by 1:v(t)?
That is, how can I calculate the mean of A(:, :, 1:v(t),t), along the third dimension, without using a loop? Is it possible to generalize this for matrices of different sizes?

Réponses (0)

Catégories

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by