From 2f7e9959f0b4120441fcf9d4337ce36ef95744a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 16 Oct 2013 13:04:48 +0200 Subject: [PATCH] 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). --- matlab/@dates/dates.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/matlab/@dates/dates.m b/matlab/@dates/dates.m index 327e50eee..695b75994 100644 --- a/matlab/@dates/dates.m +++ b/matlab/@dates/dates.m @@ -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})