Getting a mean of only the numbers

I have a dataset and I want the mean value of the numbers. There are a lot of NaN-values in there and I want to ignore those (the code
mean(data)
now gives 'NaN' as answer) How do I do this?

 Accepted Answer

Evelyn, use
mean(data(~isnan(data)))

More Answers (1)

Thorsten
Thorsten on 9 Oct 2014
Use nanmean

1 Comment

That's another option. You need to have access to the Statistics Toolbox though.

Sign in to comment.

Tags

Asked:

on 9 Oct 2014

Commented:

on 9 Oct 2014

Community Treasure Hunt

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

Start Hunting!