How to calculate standard deviation and mean ?

I have some values in excel (one column) and I want to use the callback function of a button to calculate the standard deviation and mean for those values. I tried this but the NaN value appears in the result box:
data = xlsread ('fileName');
a = data (:, 2)
S = std (a);
set (handles.editStd, 'String', S)
M = mean (a);
set (handles.editMean, 'String', M)

Answers (1)

Adam
Adam on 15 Jun 2018
Edited: Adam on 15 Jun 2018
Use
S = std( a, 'omitnan' )
M = mean( a, 'omitnan' )
if you don't want NaNs in your statistic

Asked:

on 15 Jun 2018

Edited:

on 15 Jun 2018

Community Treasure Hunt

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

Start Hunting!