From 2ae0812012239e0cb0ecfbb3f2b96e1388fe0280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Tue, 24 Sep 2013 16:25:43 +0200 Subject: [PATCH] Added the possibility to overwrite the time and init member of a dynSeries object (not allowed for freq, nobs and vobs). (cherry picked from commit b0d6e2b7b62809343dc685485f75b0f71070c245) --- matlab/@dynSeries/subsasgn.m | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/matlab/@dynSeries/subsasgn.m b/matlab/@dynSeries/subsasgn.m index da176ea21..796892a9f 100644 --- a/matlab/@dynSeries/subsasgn.m +++ b/matlab/@dynSeries/subsasgn.m @@ -97,8 +97,25 @@ switch length(S) end end end - case '.' % Single variable selection. - if ~isequal(S(1).subs,B.name) + case '.' + if isequal(S(1).subs,'init') && isa(B,'dynDate') + % Overwrite the init member... + A.init = B; + % ... and update freq and time members. + A.freq = A.init.freq; + A.time = A.init:(A.init+(A.nobs-1)); + return + elseif isequal(S(1).subs,'time') && isa(B,'dynDates') + % Overwrite the time member... + A.time = B; + % ... and update the freq and init members. + A.init = B(1); + A.freq = A.init.freq; + return + elseif ismember(S(1).subs,{'freq','nobs','vobs'}) + error(['dynSeries::subsasgn: You cannot overwrite ' S(1).subs ' member!']) + elseif ~isequal(S(1).subs,B.name) + % Single variable selection. if ~isequal(S(1).subs,B.name{1}) % Rename a variable. id = strmatch(S(1).subs,A.name);