www.gusucode.com > bigdata 工具箱 matlab源码程序 > bigdata/@tall/private/datetimePiece.m
function varargout = datetimePiece(fcnName, outClassName, tdt, varargin) %datetimePiece Common implementation for tall datetime day/month/year etc. % varargout = datetimePiece(fcnName, tdt, varargin) % * fcnName is 'year', 'month' etc. % * tdt will be validated to be a tall datetime % * trailing varargin will be validated to be non-tall % * Each output *must* be the same size as the tall input % % The calling function must call narginchk and nargoutchk. % Copyright 2016 The MathWorks, Inc. name = upper(fcnName); % Note the "1" here is the offset in the original calling function. checkNotTall(name, 1, varargin{:}); tdt = tall.validateType(tdt, name, {'datetime'}, 1); % Call the underlying element-wise function underlyingFcn = str2func(fcnName); [varargout{1:nargout}] = elementfun(@(x) underlyingFcn(x, varargin{:}), tdt); % Apply an appropriate adaptor. if isempty(outClassName) adaptor = matlab.bigdata.internal.adaptors.GenericAdaptor(); else adaptor = matlab.bigdata.internal.adaptors.getAdaptorForType(outClassName); end % Copy size from the sole tall argument if known adaptor = copySizeInformation(adaptor, tdt.Adaptor); for idx = 1:nargout varargout{idx}.Adaptor = adaptor; end end