nanmean giving nansum output

3 ビュー (過去 30 日間)
Ralph Andrews
Ralph Andrews 2023 年 2 月 13 日
コメント済み: Ralph Andrews 2023 年 2 月 13 日
function 'nanmean' is behaving like nansum and I don't know why. the help command (image below) is also referencing nansum's functionality.
any ideas? i recently updated to 2022b..

採用された回答

the cyclist
the cyclist 2023 年 2 月 13 日
That's not the help I get for nanmean (in the Statistics and Machine Learning Toolbox). Looks like there is a nanmean in the Financial Toolbox as well, but this seems like odd behavior.
Is it possible that nanmean points to a user-defined function instead? What output do you get from
which nanmean -all
  1 件のコメント
Ralph Andrews
Ralph Andrews 2023 年 2 月 13 日
ahh yes, thank you, that's exactly what i needed to see.
looks like i had a few competing nanmean functions and i have now moved the toolbox/stats one up in the path :)

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

その他の回答 (1 件)

Matt J
Matt J 2023 年 2 月 13 日
移動済み: Matt J 2023 年 2 月 13 日
function 'nanmean' is behaving like nansum
In what way? Example?
i recently updated to 2022b..
If so, why use nanmean at all? As the documentation told you, it's obsolete. Instead, use
Y=mean(X,dim,'omitnan')
  4 件のコメント
the cyclist
the cyclist 2023 年 2 月 13 日
@Ralph Andrews, I would at least consider using the (officially recommended) syntax that @Matt J shared.
I don't know how experienced a user you are, but my perspective is that a little bit of extra typing is always worth some extra robustness and code clarity. (I would definitely not use 'o' instead of 'omitnan', though!)
At the very least, I would suggest reading the version history of nanmean, and understand the reasons that it is not recommended. (But, there are no plans to remove that function, so you are safe in that sense.)
Ralph Andrews
Ralph Andrews 2023 年 2 月 13 日
that's cool i didn't think about wrapping it in a function, i definitely find it a lot more fiddly and time consuming to insert 'omitnan' flags instead of just 'nanmean'. and that's interesting to see why nanmean is not preferred, but i think for my usages nanmean does the job just fine :)

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

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by