Averaging over certain elements in an array ?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!