Averaging over certain elements in an array ?

Hi, I have the following array :
a=[1,1,1;1,2,1;1,3,1;1,7,1;1,8,1;2,4,2;4,5,2;4,6,2;3,3,3;4,5,3;5,6,4;];
rn = unique(a(:,3));
I would like to average all the a(:,1) & a(:,2) such that a(:,3) belongs to elements of rn, and store it another array, say C. For example, in this case, I would like to average C(1,1)=mean(a(1:5,1)), C(1,2)=mean(a(1:5,2)) , C(2,1)=mean(a(6:8,1)), C(2,2)=mean(a(6:8,2)) ... and so on

 Réponse acceptée

Plus de réponses (0)

Catégories

En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by