How to perform calculations on common elements of an array
Show older comments
I have A_names =[a,a,a,b,b,c,c,c,c]; B_values = [1,2,3,2,2,3,4,4,4]; length(A_names) = length(B_values). I need to find average of B_values for the common elements of A_names
Accepted Answer
More Answers (1)
Adam Danz
on 20 Jun 2018
You can loop through unique values of A_names. Here's a hint to get you started.
A_names ={'a','a','a','b','b','c','c','c','c'};
unqA = unique(A_names);
m = mean(B_values(strcmp(A_names,unqA{1})));
1 Comment
harshpurohit11
on 21 Jun 2018
Categories
Find more on Repeated Measures and MANOVA 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!