Median that ignores Nans

1 回表示 (過去 30 日間)
Ger
Ger 2011 年 7 月 19 日
Hello,
just wondering if anyone can help me with the Median function?
I have long-term rainfall data in a matrix of 306 stations by 149 years (as I have already chosen a month) with rainfall in millimetres or NaNs for no values. I previously have been able to get the mean value for all years for each station by using
z = nanmean(values) ;
Now I would like to get the median for a chosen column but my results keep coming up with the median being NaNs for most stations.
Is anyone able to help with this?
Thankyou
  1 件のコメント
Ger
Ger 2011 年 7 月 19 日
i realise that what i actually need is nanmedian but it doesn't appear to be in my version of MATLAB R2011a.
Would anyone have that file to exchange?
thanks

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 7 月 19 日
Out = arrayfun(@(i1)median(In(~isnan(In(:,i1)),i1)),1:size(In,2));
  1 件のコメント
Ger
Ger 2011 年 7 月 19 日
thanks, that worked perfectly

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

その他の回答 (0 件)

カテゴリ

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