Median that ignores Nans

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 commentaire

Ger
Ger le 19 Juil 2011
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

Connectez-vous pour commenter.

 Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 19 Juil 2011

1 vote

Out = arrayfun(@(i1)median(In(~isnan(In(:,i1)),i1)),1:size(In,2));

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by