MATLAB: Normalise a Histogram excluding NaN

histogramnanpdf

Shown under M1, i am attempting to plot a histogram and it's Normal Distribution, however the data has a large quantity of NaN. I was able to omit them in the plotting for the line but not the histogram bars themselves.
Does anyone know how to fix this?

Best Answer

One option is:
histogram(m(~isnan(m)), 50, 'Normalization','PDF')
This eliminates the NaN values from your data before doing the analysis.
Experiment to get the result you want.