diff --git a/src/@dseries/dseries.m b/src/@dseries/dseries.m index e51a6a9b6a003ba11cafa899025dcdf6d4c5b0db..2b7c78c669832ed374ecae0672e43d09998772cf 100644 --- a/src/@dseries/dseries.m +++ b/src/@dseries/dseries.m @@ -50,12 +50,6 @@ methods switch nargin case 0 % Return empty object. - o.data = []; - o.name = {}; - o.tex = {}; - o.dates = dates(); - o.ops = {}; - o.tags = struct(); return case 1 if isdates(varargin{1}) @@ -64,24 +58,14 @@ methods error('dseries:WrongInputArguments', 'Input (identified as a dates object) must be non empty!'); case 1 % Create an empty dseries object with an initial date. - o.data = []; - o.name = {}; - o.tex = {}; o.dates = varargin{1}; - o.ops = {}; - o.tags = struct(); otherwise error('dseries:WrongInputArguments', 'Input (identified as a dates object) must have a unique element!'); end return elseif ischar(varargin{1}) - [init, data, varlist, tex, ops, tags] = load_data(varargin{1}); - o.data = data; - o.name = varlist; + [init, o.data, o.name, o.tex, o.ops, o.tags] = load_data(varargin{1}); o.dates = init:init+(nobs(o)-1); - o.tex = tex; - o.ops = ops; - o.tags = tags; elseif ~isoctave() && ~matlab_ver_less_than('8.2') && istable(varargin{1}) % It is assumed that the dates are in the first column. o.name = varargin{1}.Properties.VariableNames(2:end); @@ -89,14 +73,12 @@ methods o.data = varargin{1}{:,2:end}; o.dates = dates(varargin{1}{1,1}{1})+(0:size(varargin{1}, 1)-1); o.ops = cell(length(o.name), 1); - o.tags = struct(); elseif isnumeric(varargin{1}) && isequal(ndims(varargin{1}),2) o.data = varargin{1}; o.name = default_name(vobs(o)); o.tex = name2tex(o.name); o.dates = dates(1,1):dates(1,1)+(nobs(o)-1); o.ops = cell(length(o.name), 1); - o.tags = struct(); elseif isstruct(varargin{1}) o = struct2dseries(varargin{1}); end @@ -105,26 +87,16 @@ methods % Instantiate dseries object with a data file and force the initial date to % be as given by the second input argument (initial period represented % with a dates object). - [~, data, varlist, tex, ops, tags] = load_data(varargin{1}); - o.data = data; - o.name = varlist; + [~, o.data, o.name, o.tex, o.ops, o.tags] = load_data(varargin{1}); o.dates = varargin{2}:varargin{2}+(nobs(o)-1); - o.tex = tex; - o.ops = ops; - o.tags = tags; return end if isequal(nargin,2) && ischar(varargin{1}) && ischar(varargin{2}) && isdate(varargin{2}) % Instantiate dseries object with a data file and force the initial date to % be as given by the second input argument (initial period represented with a % string). - [~, data, varlist, tex, ops, tags] = load_data(varargin{1}); - o.data = data; - o.name = varlist; + [~, o.data, o.name, o.tex, o.ops, o.tags] = load_data(varargin{1}); o.dates = dates(varargin{2}):dates(varargin{2})+(nobs(o)-1); - o.tex = tex; - o.ops = ops; - o.tags = tags; return end a = varargin{1};