How to calculate standard deviation and mean ?
Show older comments
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)
Use
S = std( a, 'omitnan' )
M = mean( a, 'omitnan' )
if you don't want NaNs in your statistic
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!