How do I sum over multiple dimensions? I want my final result to be a average with respect to area not the number of grids.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nesha Wright
le 20 Juin 2018
Commenté : Nesha Wright
le 20 Juin 2018
When I use the sum command it sums the rows (A=sum(b)). I want a global average (emissions/space) as my final value and I keep getting a massive array. I need the sum of the first array divided by the sum of the second array. The first array is 4D.
0 commentaires
Réponse acceptée
Image Analyst
le 20 Juin 2018
"I need the sum of the first array divided by the sum of the second array."
Try this:
ratio = sum(array4D(:)) / sum(otherArray(:));
None of us have any idea what you're talking about when you talk about grids, but you might check out the FAQ: https://matlab.wikia.com/wiki/FAQ#How_do_I_split_an_image_into_non-overlapping_blocks.3F or see the attached demos.
0 commentaires
Plus de réponses (1)
Guillaume
le 20 Juin 2018
mean(yourarray(:))
No need to use sum to calculate the mean.
3 commentaires
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!