taking special average of numbers
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Neesha
le 12 Sep 2014
Réponse apportée : Andrei Bobrov
le 12 Sep 2014
I have two field in dataser as below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145374/image.jpeg)
the answer you see as C labeled row, is A1*B1 + A2*B2 + A3*B3 = weightedA A1 + A2 + A3 = totalA so C1 = weightedA/totalA
now do the same for next 3 numbers and so on.
How do i do that in matlab?
0 commentaires
Réponse acceptée
Andrei Bobrov
le 12 Sep 2014
ab = randi(100,2,12); % here ab - your array
ab2 = permute(reshape(ab,2,3,[]),[2 3 1]);
ab(3,3:3:end) = dot(ab2(:,:,1),ab2(:,:,2))./sum(ab2(:,:,1);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings 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!