Changed dates constructor so that an object can be instantiated by passing the freq and time member or the freq member, the first column of the time member and the second column of the time member (mandatory only for non annual frequency).

time-shift
Stéphane Adjemian (Charybdis) 2013-10-16 13:04:48 +02:00
parent f28bc166f6
commit 2f7e9959f0
1 changed files with 8 additions and 3 deletions

View File

@ -89,14 +89,19 @@ switch nargin
error('dates:: Wrong calling sequence of the constructor!')
end
otherwise
dd.ndat = nargin;
dd.time = NaN(dd.ndat,2);
if isdate(varargin{1})
dd.ndat = nargin;
dd.time = NaN(dd.ndat,2);
date = string2date(varargin{1});
dd.freq = date.freq;
dd.time(1,:) = date.time;
elseif isfreq(varargin{1})
S.type = '()';
S.subs = varargin;
dd = subsref(dd,S);
return
else
error(['dates::dates: Input 1 has to be a string date!'])
error(['dates::dates: Wrong calling sequence!'])
end
for i=2:dd.ndat
if isdate(varargin{i})