diff --git a/matlab/reports/@graph/addSeries.m b/matlab/reports/@graph/addSeries.m
new file mode 100644
index 000000000..ddfcb4132
--- /dev/null
+++ b/matlab/reports/@graph/addSeries.m
@@ -0,0 +1,22 @@
+function o = addSeries(o, varargin)
+% function o = addSeries(o, varargin)
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+o.seriesElements = o.seriesElements.addSeries(varargin{:});
+end
\ No newline at end of file
diff --git a/matlab/reports/@graph/createGraph.m b/matlab/reports/@graph/createGraph.m
index 98035a73a..0daf941b8 100644
--- a/matlab/reports/@graph/createGraph.m
+++ b/matlab/reports/@graph/createGraph.m
@@ -28,15 +28,11 @@ function o = createGraph(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see .
-assert(~isempty(o.data));
-
if ~isempty(o.figname)
warning('@graph.createGraph: will overwrite %s with new graph\n', ...
o.figname);
end
-%o = readConfig(o);
-
disp('creating plot..........');
h = figure('visible','off');
hold on;
@@ -45,25 +41,25 @@ if o.grid
grid on;
set(gca, 'GridLineStyle', '--');
end
-%set(0, 'CurrentFigure',h);
-%set(h, 'PaperPositionMode', 'auto');
-%set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]);
-if isempty(o.seriestouse)
- ds = o.data;
-else
- ds = o.data{o.seriestouse{:}};
+ne = o.seriesElements.numel();
+dd = dynDates();
+for i=1:ne
+ ddt = o.seriesElements(i).getLine(o.xrange);
+ if isempty(dd)
+ dd = ddt;
+ continue
+ end
+ if ddt(1) < dd(1)
+ dd = union(ddt(1):dd(1), dd);
+ end
+ if ddt(ddt.ndat) > dd(dd.ndat)
+ dd = union(dd, dd(dd.ndat):ddt(ddt.ndat));
+ end
end
-if ~isempty(o.xrange)
- ds = ds(o.xrange);
-end
-data = ds.data;
-
-x = 1:1:ds.nobs;
-xlabels = getDatesCellStringArray(ds.time);
-
-plot(x, data);
+x = 1:1:dd.ndat;
+xlabels = getDatesCellStringArray(dd);
if ~isempty(o.yrange)
ylim(o.yrange);
@@ -87,7 +83,7 @@ set(gca,'XTick', x);
set(gca,'XTickLabel', xlabels);
if o.legend
- lh = legend(ds.name);
+ lh = legend(o.seriesElements.getNames());
set(lh, 'orientation', o.legend_orientation);
set(lh, 'Location', o.legend_location);
set(lh, 'FontSize', o.legend_font_size);
diff --git a/matlab/reports/@graph/display.m b/matlab/reports/@graph/display.m
index 7938abb45..b05877a95 100644
--- a/matlab/reports/@graph/display.m
+++ b/matlab/reports/@graph/display.m
@@ -54,16 +54,6 @@ disp([name '.figname = ']);
disp(' ');
disp([' ''' o.figname '''']);
-disp(' ');
-disp([name '.data = ']);
-disp(' ');
-display(o.data);
-
-disp(' ');
-disp([name '.seriestoplot = ']);
-disp(' ');
-disp(o.seriestoplot);
-
disp(' ');
disp([name '.config = ']);
disp(' ');
@@ -78,4 +68,9 @@ disp(' ');
disp([name '.shade = ']);
disp(' ');
disp(o.shade);
+
+disp(' ');
+disp([name '.seriesElements = ']);
+disp(' ');
+o.seriesElements.getSeriesElements()
end
\ No newline at end of file
diff --git a/matlab/reports/@graph/graph.m b/matlab/reports/@graph/graph.m
index 56fd9518e..c1a16a030 100644
--- a/matlab/reports/@graph/graph.m
+++ b/matlab/reports/@graph/graph.m
@@ -35,6 +35,8 @@ o = struct;
o.config = '';
+o.seriesElements = seriesElements();
+
o.title = '';
o.ylabel = '';
o.xlabel = '';
@@ -112,11 +114,26 @@ assert(isempty(o.yrange) || (isfloat(o.yrange) && length(o.yrange) == 2 && ...
o.yrange(1) < o.yrange(2)), ...
['@graph.graph: yrange is specified an array with two float entries, ' ...
'the lower bound and upper bound.']);
-assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ['@graph.graph: must ' ...
- 'provide data as a dynSeries']);
+assert(isempty(o.data) || isa(o.data, 'dynSeries'), ['@graph.graph: data must ' ...
+ 'be a dynSeries']);
assert(isempty(o.seriestouse) || iscellstr(o.seriestouse), ['@graph.graph: ' ...
'series to use must be a cell array of string(s)']);
+% using o.seriestouse, create series objects and put them in o.seriesElements
+if ~isempty(o.data)
+ if isempty(o.seriestouse)
+ for i=1:o.data.vobs
+ o.seriesElements = o.seriesElements.addSeries('data', o.data{o.name{i}});
+ end
+ else
+ for i=1:length(o.seriestouse)
+ o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriestouse{i}});
+ end
+ end
+end
+o = rmfield(o, 'seriestouse');
+o = rmfield(o, 'data');
+
% Create graph object
o = class(o, 'graph');
end
\ No newline at end of file
diff --git a/matlab/reports/@graph/subsasgn.m b/matlab/reports/@graph/subsasgn.m
index 8ab064094..fb645de5b 100644
--- a/matlab/reports/@graph/subsasgn.m
+++ b/matlab/reports/@graph/subsasgn.m
@@ -29,6 +29,10 @@ if length(S) > 1
end
switch S.type
+ case '()'
+ index = S.subs{:};
+ assert(isnumeric(index));
+ B.seriesElements(index) = V;
case '.'
switch S.subs
case fieldnames(A)
diff --git a/matlab/reports/@graph/subsref.m b/matlab/reports/@graph/subsref.m
index 1610116f7..d25f47fa3 100644
--- a/matlab/reports/@graph/subsref.m
+++ b/matlab/reports/@graph/subsref.m
@@ -33,7 +33,9 @@ switch S(1).type
otherwise
error(['@graph.subsref: unknown field or method: ' S(1).subs]);
end
- case {'()', '{}'}
+ case '()'
+ A = A.seriesElements.getSeriesElements(S(1).subs{:});
+ case '{}'
error(['@graph.subsref: ' S(1).type ' indexing not supported.']);
otherwise
error('@graph.subsref: impossible case')
diff --git a/matlab/reports/@section/element.m b/matlab/reports/@section/element.m
new file mode 100644
index 000000000..7aab80960
--- /dev/null
+++ b/matlab/reports/@section/element.m
@@ -0,0 +1,23 @@
+function o = element(o, index)
+% function o = element(o, index)
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+assert(isint(index));
+o = o.elements(index);
+end
\ No newline at end of file
diff --git a/matlab/reports/@section/subsasgn.m b/matlab/reports/@section/subsasgn.m
index 79f3af53a..a0a7a1164 100644
--- a/matlab/reports/@section/subsasgn.m
+++ b/matlab/reports/@section/subsasgn.m
@@ -32,8 +32,15 @@ switch S.type
case '()'
index = S.subs{:};
assert(isnumeric(index));
- B(index) = V;
+ B.elements(index) = V;
+ case '.'
+ switch S.subs
+ case fieldnames(A)
+ B.(S.subs) = V;
+ otherwise
+ error(['@section.subsasgn: field ' S.subs 'does not exist']);
+ end
otherwise
- error('@section.subsasgn: syntax error')
+ error('@section.subsasgn: syntax error');
end
end
\ No newline at end of file
diff --git a/matlab/reports/@series/getName.m b/matlab/reports/@series/getName.m
new file mode 100644
index 000000000..4296e9bc6
--- /dev/null
+++ b/matlab/reports/@series/getName.m
@@ -0,0 +1,23 @@
+function s = getName(o)
+%function s = getName(o)
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+assert(~isempty(o.data) && numel(o.data) == 1);
+s = o.data(1).name();
+end
\ No newline at end of file
diff --git a/matlab/reports/@seriesElements/addSeries.m b/matlab/reports/@seriesElements/addSeries.m
new file mode 100644
index 000000000..3c683576c
--- /dev/null
+++ b/matlab/reports/@seriesElements/addSeries.m
@@ -0,0 +1,22 @@
+function o = addSeries(o, varargin)
+% function o = addSeries(o, varargin)
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+o.objArray = o.objArray.addObj(series(varargin{:}));
+end
\ No newline at end of file
diff --git a/matlab/reports/@seriesElements/display.m b/matlab/reports/@seriesElements/display.m
new file mode 100644
index 000000000..38061b3e9
--- /dev/null
+++ b/matlab/reports/@seriesElements/display.m
@@ -0,0 +1,37 @@
+function display(o)
+%function display(o)
+% Display a Elements object
+%
+% INPUTS
+% none
+%
+% OUTPUTS
+% none
+%
+% SPECIAL REQUIREMENTS
+% none
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+name = 'report.page.section.elements.seriesElement';
+
+disp(' ');
+disp([name ' = ']);
+disp(' ');
+disp(getSeriesElements(o));
+end
\ No newline at end of file
diff --git a/matlab/reports/@seriesElements/getNames.m b/matlab/reports/@seriesElements/getNames.m
new file mode 100644
index 000000000..cbb29b3ed
--- /dev/null
+++ b/matlab/reports/@seriesElements/getNames.m
@@ -0,0 +1,26 @@
+function names = getNames(o, varargin)
+% function names = getNames(o, varargin)
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+se = o.objArray.getObjs(varargin{:});
+names = {};
+for i=1:length(se)
+ names(i) = se{i}.getName();
+end
+end
\ No newline at end of file
diff --git a/matlab/reports/@seriesElements/getSeriesElements.m b/matlab/reports/@seriesElements/getSeriesElements.m
new file mode 100644
index 000000000..1a9dcd2ab
--- /dev/null
+++ b/matlab/reports/@seriesElements/getSeriesElements.m
@@ -0,0 +1,22 @@
+function o = getSeriesElements(o, varargin)
+% function o = getSeriesElements(o, varargin)
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+o = o.objArray.getObjs(varargin{:});
+end
\ No newline at end of file
diff --git a/matlab/reports/@seriesElements/numel.m b/matlab/reports/@seriesElements/numel.m
new file mode 100644
index 000000000..e52bd8031
--- /dev/null
+++ b/matlab/reports/@seriesElements/numel.m
@@ -0,0 +1,22 @@
+function n = numel(o)
+% function n = numel(o)
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+n = o.objArray.numObjs();
+end
\ No newline at end of file
diff --git a/matlab/reports/@seriesElements/seriesElements.m b/matlab/reports/@seriesElements/seriesElements.m
new file mode 100644
index 000000000..a6bd3ebce
--- /dev/null
+++ b/matlab/reports/@seriesElements/seriesElements.m
@@ -0,0 +1,42 @@
+function o = seriesElements(varargin)
+%function o = seriesElements(varargin)
+% SeriesElements Class Constructor
+%
+% INPUTS
+% Optional seriesElements object
+%
+% OUTPUTS
+% seriesElements object
+%
+% SPECIAL REQUIREMENTS
+% none
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+switch nargin
+ case 0
+ o = class(struct, 'seriesElements', objArray());
+ case 1
+ assert(isa(varargin{1}, 'seriesElements'), ...
+ ['@seriesElements.seriesElements: with one arg, you must pass an seriesElements ' ...
+ 'object or a char.']);
+ o = varargin{1};
+ otherwise
+ error('@seriesElements.seriesElements: invalid number of arguments');
+end
+end
\ No newline at end of file
diff --git a/matlab/reports/@seriesElements/subsasgn.m b/matlab/reports/@seriesElements/subsasgn.m
new file mode 100644
index 000000000..fab53a73c
--- /dev/null
+++ b/matlab/reports/@seriesElements/subsasgn.m
@@ -0,0 +1,39 @@
+function B = subsasgn(A, S, V)
+% function B = subsasgn(A, S, V)
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+B = A;
+if length(S) > 1
+ for i=1:(length(S)-1)
+ B = subsref(B, S(i));
+ end
+ B = subsasgn(B, S(end), V);
+ B = subsasgn(A, S(1:(end-1)), B);
+ return
+end
+
+switch S.type
+ case '()'
+ index = S.subs{:};
+ assert(isnumeric(index));
+ B.objArray(index) = V;
+ otherwise
+ error('@seriesElements.subsasign: syntax error');
+end
+end
\ No newline at end of file
diff --git a/matlab/reports/@seriesElements/subsref.m b/matlab/reports/@seriesElements/subsref.m
new file mode 100644
index 000000000..f4c171abd
--- /dev/null
+++ b/matlab/reports/@seriesElements/subsref.m
@@ -0,0 +1,48 @@
+function A = subsref(A, S)
+%function A = subsref(A, S)
+
+% Copyright (C) 2013 Dynare Team
+%
+% This file is part of Dynare.
+%
+% Dynare is free software: you can redistribute it and/or modify
+% it under the terms of the GNU General Public License as published by
+% the Free Software Foundation, either version 3 of the License, or
+% (at your option) any later version.
+%
+% Dynare is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+% 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 .
+
+switch S(1).type
+ case '.'
+ switch S(1).subs
+ case fieldnames(A)
+ A = A.(S(1).subs);
+ case methods(A)
+ if areParensNext(S)
+ A = feval(S(1).subs, A, S(2).subs{:});
+ S = shiftS(S);
+ else
+ A = feval(S(1).subs, A);
+ end
+ otherwise
+ error(['@seriesElements.subsref: unknown field or method: ' S(1).subs]);
+ end
+ case '()'
+ A = getSeriesElements(A, S(1).subs{:});
+ case '{}'
+ error(['@seriesElements.subsref: ' S(1).type ' indexing not supported.']);
+ otherwise
+ error('@seriesElements.subsref: impossible case');
+end
+
+S = shiftS(S);
+if length(S) >= 1
+ A = subsref(A, S);
+end
+end