www.gusucode.com > bigdata 工具箱 matlab源码程序 > bigdata/@tall/std.m
function stdX = std(x, flag, varargin) %STD Standard deviation % Supported syntaxes: % Y = STD(X) % Y = STD(X,FLAG) where FLAG is 0 or 1 % Y = STD(X,FLAG,DIM) % Y = STD(...,MISSING) % Copyright 2015-2016 The MathWorks, Inc. x = tall.validateType(x, mfilename, {'numeric', 'logical', 'duration', 'datetime'}, 1); if nargin < 2 flag = 0; end if nargin == 2 && (ischar(flag) || isstring(flag)) % Presume 'flag' is actually a 'missing' indicator varargin = {flag}; flag = 0; end if ~(isnumeric(flag) && ~isobject(flag) && isscalar(flag)) error(message('MATLAB:bigdata:array:WeightVectorNotSupported', 'STD')); end checkNotTall(upper(mfilename), 2, varargin{:}); % Preceding two checks ensure that x is tall assert(istall(x), 'Data input to STD must be tall.'); if strcmp(x.Adaptor.Class, 'datetime') % Cannot support STD for datetime error(message('MATLAB:bigdata:array:FcnNotSupportedForType', ... upper(mfilename), 'datetime')); elseif strcmp(x.Adaptor.Class, 'duration') % This is essentially copied from the duration/std implementation x = milliseconds(x); % TODO(g1361570): need to preserve Format field here. fixOutput = @(result) duration(0, 0, 0, result); else fixOutput = @(result) result; end stdX = sqrt(var(x, flag, varargin{:})); stdX = fixOutput(stdX); end