From 7e6eb2fbaba26231180d9402663e6e67282c089c Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Fri, 3 Jan 2014 16:04:39 +0100 Subject: [PATCH] reporting: support monthly data in table --- matlab/reports/@report_table/write.m | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/matlab/reports/@report_table/write.m b/matlab/reports/@report_table/write.m index 38e57c3ef..6f2d023d9 100644 --- a/matlab/reports/@report_table/write.m +++ b/matlab/reports/@report_table/write.m @@ -133,7 +133,28 @@ switch dates.freq end end case 12 - error('@report_table.write: weekly dates not yet implemented'); + thdr{1, 2} = datedata(:, 2)'; + if size(thdr, 1) > 1 + for i=2:size(thdr, 1) + split = find(thdr{i-1, 2} == 12, 1, 'first'); + assert(~isempty(split), '@report_table.write 2: Shouldn''t arrive here'); + thdr{i, 2} = thdr{i-1, 2}(split+1:end); + thdr{i-1, 2} = thdr{i-1, 2}(1:split); + end + end + for i=1:size(thdr, 1) + fprintf(fid, ' & \\multicolumn{%d}{c}{%d}', size(thdr{i,2}, 2), thdr{i,1}); + end + for i=1:length(rhscols) + fprintf(fid, ' & %s', rhscols{i}); + end + fprintf(fid, '\\\\\\cline{%d-%d}%%\n', nlhc+1, ncols); + for i=1:size(thdr, 1) + months = thdr{i, 2}; + for j=1:size(months, 2) + fprintf(fid, ' & \\multicolumn{1}{c}{M%d}', months(j)); + end + end otherwise error('@report_table.write: invalid dseries frequency'); end -- GitLab