2019-08-27 17:38:20 +02:00
|
|
|
function writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor)
|
|
|
|
%function writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor)
|
2013-04-02 15:00:00 +02:00
|
|
|
% Write Table Row
|
|
|
|
%
|
|
|
|
% INPUTS
|
2013-10-18 15:20:09 +02:00
|
|
|
% o [report_series] report_series object
|
2013-10-28 15:04:21 +01:00
|
|
|
% fid [int] file id
|
|
|
|
% dates [dates] dates for report_series slice
|
|
|
|
% precision [float] precision with which to print the data
|
2014-07-28 16:32:17 +02:00
|
|
|
% ncols [int] total number of columns in table
|
2014-07-30 15:19:39 +02:00
|
|
|
% rowcolor [string] string to color this row
|
2013-09-26 16:34:36 +02:00
|
|
|
%
|
2013-04-02 15:00:00 +02:00
|
|
|
%
|
|
|
|
% OUTPUTS
|
2013-10-18 15:20:09 +02:00
|
|
|
% o [report_series] report_series object
|
2013-04-02 15:00:00 +02:00
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
|
|
|
|
2022-04-13 13:14:04 +02:00
|
|
|
% Copyright © 2013-2019 Dynare Team
|
2013-04-02 15:00:00 +02:00
|
|
|
%
|
|
|
|
% 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
|
2021-06-09 17:15:17 +02:00
|
|
|
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2013-04-02 15:00:00 +02:00
|
|
|
|
|
|
|
%% Validate options passed to function
|
2014-01-02 15:28:23 +01:00
|
|
|
for i=1:length(dates)
|
2014-05-20 14:47:37 +02:00
|
|
|
assert(isdates(dates{i}));
|
2014-01-02 15:28:23 +01:00
|
|
|
end
|
2013-04-02 15:00:00 +02:00
|
|
|
assert(isint(precision));
|
|
|
|
|
|
|
|
%% Validate options provided by user
|
2014-02-13 15:25:54 +01:00
|
|
|
assert(ischar(o.tableSubSectionHeader), '@report_series.writeSeriesForTable: tableSubSectionHeader must be a string');
|
2013-09-26 14:37:33 +02:00
|
|
|
if isempty(o.tableSubSectionHeader)
|
2014-05-20 14:50:28 +02:00
|
|
|
assert(~isempty(o.data) && isdseries(o.data), ...
|
2014-02-13 15:25:54 +01:00
|
|
|
'@report_series.writeSeriesForTable: must provide data as a dseries');
|
2014-01-02 15:28:23 +01:00
|
|
|
|
|
|
|
if ~isempty(o.tableDataRhs)
|
2014-05-20 14:50:28 +02:00
|
|
|
assert(~isempty(o.tableDataRhs) && isdseries(o.tableDataRhs), ...
|
2014-02-13 15:25:54 +01:00
|
|
|
'@report_series.writeSeriesForTable: must provide tableDataRhs as a dseries');
|
2014-01-02 15:28:23 +01:00
|
|
|
assert(iscell(dates) && length(dates) == 2, ...
|
2014-02-13 15:25:54 +01:00
|
|
|
'@report_series.writeSeriesForTable: must provide second range with tableDataRhs');
|
2014-01-02 15:28:23 +01:00
|
|
|
end
|
2013-09-26 14:37:33 +02:00
|
|
|
end
|
2013-04-02 15:00:00 +02:00
|
|
|
|
2014-02-13 15:25:54 +01:00
|
|
|
assert(ischar(o.tableNegColor), '@report_series.writeSeriesForTable: tableNegColor must be a string');
|
|
|
|
assert(ischar(o.tablePosColor), '@report_series.writeSeriesForTable: tablePosColor must be a string');
|
|
|
|
assert(ischar(o.tableRowColor), '@report_series.writeSeriesForTable: tableRowColor must be a string');
|
2014-07-28 15:06:03 +02:00
|
|
|
assert(isint(o.tableRowIndent) && o.tableRowIndent >= 0, ...
|
|
|
|
'@report_series.writeSeriesForTable: tableRowIndent must be an integer >= 0');
|
2014-02-13 15:25:54 +01:00
|
|
|
assert(islogical(o.tableShowMarkers), '@report_series.writeSeriesForTable: tableShowMarkers must be true or false');
|
|
|
|
assert(islogical(o.tableAlignRight), '@report_series.writeSeriesForTable: tableAlignRight must be true or false');
|
|
|
|
assert(isfloat(o.tableMarkerLimit), '@report_series.writeSeriesForTable: tableMarkerLimit must be a float');
|
2016-02-22 10:56:25 +01:00
|
|
|
assert(ischar(o.tableNaNSymb), '@report_series.writeSeriesForTable: tableNaNSymb must be a string');
|
2013-04-02 15:00:00 +02:00
|
|
|
|
2017-01-09 16:12:29 +01:00
|
|
|
if ~isempty(o.tablePrecision)
|
|
|
|
assert(isint(o.tablePrecision) && o.tablePrecision >= 0, ...
|
|
|
|
'@report_series.writeSeriesForTable: tablePrecision must be a non-negative integer');
|
|
|
|
precision = o.tablePrecision;
|
|
|
|
end
|
|
|
|
|
2013-04-02 15:00:00 +02:00
|
|
|
%% Write Output
|
2013-10-18 15:20:09 +02:00
|
|
|
fprintf(fid, '%% Table Row (report_series)\n');
|
2014-07-30 15:19:39 +02:00
|
|
|
if ~isempty(o.tableRowColor) && ~strcmpi(o.tableRowColor, 'white')
|
|
|
|
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
|
|
|
|
elseif ~isempty(rowcolor)
|
|
|
|
fprintf(fid, '\\rowcolor{%s}', rowcolor);
|
|
|
|
else
|
2013-09-25 14:11:58 +02:00
|
|
|
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
|
|
|
|
end
|
2013-09-26 14:37:33 +02:00
|
|
|
if ~isempty(o.tableSubSectionHeader)
|
2014-07-28 17:28:00 +02:00
|
|
|
fprintf(fid, '\\textbf{%s}', o.tableSubSectionHeader);
|
2014-07-28 16:32:17 +02:00
|
|
|
for i=1:ncols-1
|
|
|
|
fprintf(fid, ' &');
|
|
|
|
end
|
2013-09-26 14:37:33 +02:00
|
|
|
fprintf(fid, '\\\\%%\n');
|
2019-09-02 17:45:12 +02:00
|
|
|
return
|
2013-09-26 14:37:33 +02:00
|
|
|
end
|
2013-05-13 17:06:48 +02:00
|
|
|
if o.tableAlignRight
|
2013-04-03 16:28:17 +02:00
|
|
|
fprintf(fid, '\\multicolumn{1}{r}{');
|
|
|
|
end
|
2014-01-24 16:53:53 +01:00
|
|
|
if o.tableRowIndent == 0
|
|
|
|
fprintf(fid, '\\noindent');
|
|
|
|
else
|
|
|
|
for i=1:o.tableRowIndent
|
|
|
|
fprintf(fid,'\\indent');
|
|
|
|
end
|
|
|
|
end
|
|
|
|
fprintf(fid, ' %s', o.data.tex{:});
|
2013-05-13 17:06:48 +02:00
|
|
|
if o.tableAlignRight
|
2013-04-03 16:28:17 +02:00
|
|
|
fprintf(fid, '}');
|
|
|
|
end
|
2013-04-02 15:00:00 +02:00
|
|
|
|
2014-01-02 15:28:23 +01:00
|
|
|
printSeries(o, fid, o.data, dates{1}, precision);
|
|
|
|
if ~isempty(o.tableDataRhs)
|
|
|
|
printSeries(o, fid, o.tableDataRhs, dates{2}, precision);
|
2013-04-02 15:00:00 +02:00
|
|
|
end
|
2014-01-02 15:28:23 +01:00
|
|
|
|
2013-09-26 14:45:46 +02:00
|
|
|
fprintf(fid, '\\\\%%\n');
|
2013-04-02 15:00:00 +02:00
|
|
|
end
|