diff --git a/matlab/@dates/dates.m b/matlab/@dates/dates.m index 8ba7efd3b..b52eb9c93 100644 --- a/matlab/@dates/dates.m +++ b/matlab/@dates/dates.m @@ -60,10 +60,14 @@ function dd = dates(varargin) % --*-- Unitary tests --*-- % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License - % along with Dynare. If not, see . +% along with Dynare. If not, see . -dd = struct('ndat', 0, 'freq', NaN(0), 'time', NaN(0,2)); -dd = class(dd,'dates'); +if exist('empty-dates-object.mat','file') + load('empty-dates-object'); +else + dd = struct('ndat', 0, 'freq', NaN(0), 'time', NaN(0,2)); + dd = class(dd,'dates'); +end switch nargin case 0 diff --git a/matlab/@dseries/dseries.m b/matlab/@dseries/dseries.m index 2c1ef6485..55ed8c3b7 100644 --- a/matlab/@dseries/dseries.m +++ b/matlab/@dseries/dseries.m @@ -76,18 +76,19 @@ function ts = dseries(varargin) % --*-- Unitary tests --*-- % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -ts = struct; - -ts.data = []; -ts.nobs = 0; -ts.vobs = 0; -ts.name = {}; -ts.tex = {}; -ts.freq = []; -ts.init = dates(); -ts.dates = dates(); - -ts = class(ts,'dseries'); +if exist('empty-dseries-object.mat','file') + load('empty-dseries-object'); +else + ts = struct; + ts.data = []; + ts.nobs = 0; + ts.vobs = 0; + ts.name = {}; + ts.tex = {}; + ts.freq = []; + ts.init = dates(); + ts.dates = dates(); +end switch nargin case 0 diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m index cbdf251b7..a92b33248 100644 --- a/matlab/dynare_config.m +++ b/matlab/dynare_config.m @@ -250,4 +250,18 @@ if verbose skipline() end +% Delete empty dates and dseries saved on disk. +if exist('empty-dates-object.mat','file') + delete([dynareroot 'empty-dates-object.mat']); +end +if exist('empty-dseries-object.mat','file') + delete([dynareroot 'empty-dseries-object.mat']); +end + +% Save empty dates and dseries objects on disk. +dd = dates(); +ts = dseries(); +save([dynareroot 'empty-dates-object.mat'],'dd'); +save([dynareroot 'empty-dseries-object.mat'],'ts'); + cd(origin);