MATLAB: Error using nanstd function

nannanstd

B=nanstd(X,0,'all');
when using the above statement in Matlab R2019a there are no problems, however when using it on another computer with R2017a, i get the error:
Error using size
Dimension argument must be a positive integer scalar within indexing range.
Error in var (line 109)
n = size(x,dim);
Error in nanvar (line 32)
y = var(varargin{:},'omitnan');
Error in nanstd (line 28)
y = sqrt(nanvar(varargin{:}));

Best Answer

If you're computing the std over all elements of X, this works in any release.
B = std(X(~isnan(X)));