Element wise mean produces an incorrect result

1 回表示 (過去 30 日間)
manuel FOSSA
manuel FOSSA 2017 年 4 月 3 日
コメント済み: David Goodmanson 2017 年 4 月 7 日
Hi,
I have a x*n*t array. The array represent some atmospheric measure at location (x,y) and time t. 'field_example' (attached) is an example of field at t=1; I want to compute the time averaged field. So easy, just do
if true
mean_array = mean(array,3)
end
My problem is that doing so produces the 'problem_field' plot. As you can see this can't be the mean of an atmospheric field as there's no spatial correlation between values. I found out that what was giving that problem was the last time field, that is when t=T. But my field at time T is actually pretty normal. Proof of it, and the strangest thing, is that if do
if true
tmp = mean(array(:,:,1:end-1),3);
mean_array = (tmp+array(:,:,end))./2;
end
It produces the 'correct_field'!
Any idea of why it is doing that?
  8 件のコメント
manuel FOSSA
manuel FOSSA 2017 年 4 月 7 日
編集済み: manuel FOSSA 2017 年 4 月 7 日
Thank you David, i need to check why the sum is zero..this is very surprising.
David Goodmanson is accepted answer. (please feel free to put it as answer)
David Goodmanson
David Goodmanson 2017 年 4 月 7 日
thank you manuel for your answer offer, I did that.

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

採用された回答

David Goodmanson
David Goodmanson 2017 年 4 月 7 日
hello manuel, What's going on is that for whatever reason, the sum in the third dimension of all your slices equals zero within numerical error. The 71x46 different sums are all down around 1e-15 and the elements themselves are of both signs, as if someone has subtracted off the mean already. If you sum all except for one of these you get a reasonable result, but if you sum them all you get a plot of autoscaled numerical confetti.

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by