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 ビュー (過去 30 日間)
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.

採用された回答

Image Analyst
Image Analyst 2018 年 6 月 20 日
"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.

その他の回答 (1 件)

Guillaume
Guillaume 2018 年 6 月 20 日
mean(yourarray(:))
No need to use sum to calculate the mean.
  3 件のコメント
Guillaume
Guillaume 2018 年 6 月 20 日
What grid squares?
I need to divide by ...
Need to divide what?
Nesha Wright
Nesha Wright 2018 年 6 月 20 日
When the command mean is used on a gridded dataset it takes the sum of the array and divides it by the number of grid cell, I need to divide it by the sum area of the grid cells, not how many there are. I could be wrong...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by