Commit d7cf8ac7 authored by Houtan Bastani's avatar Houtan Bastani

make column_names work correctly for addData

parent 29d19e4c
......@@ -26,6 +26,9 @@ classdef report_data < handle
tablePrecision = ''
zeroTol = 1e-6
end
properties
column_names = ''
end
methods
function o = report_data(varargin)
%function o = report_data(varargin)
......
......@@ -22,11 +22,10 @@ classdef report_table < handle
end
properties (Access = private)
series = {}
table_data = {}
table_data = {} % The table data
% Not documented
preamble = {''}
afterward = {''}
column_names = ''
end
properties (SetAccess = private)
tableDirName = 'tmpRepDir' % The name of the folder in which to store this table. Default: tmpRepDir.
......
......@@ -39,7 +39,9 @@ if ne == 0 && ~is_data_table
warning('@report_table.write: no series to plot, returning');
return
end
if is_data_table
ne = size(o.table_data{1}.data,2);
end
if exist([rep_dir '/' o.tableDirName], 'dir') ~= 7
mkdir([rep_dir '/' o.tableDirName]);
end
......@@ -177,8 +179,13 @@ else
if o.showVlines
fprintf(fid, '|');
end
for i = 1:length(o.column_names)
if isempty(o.column_names{i})
if ~isempty(o.table_data{1}.column_names) && ne ~= length(o.table_data{1}.column_names)
error(['@report_table.writeTableFile: when writing a data table and passing the ' ...
'`column_names` option, it must have the same number of elements as the ' ...
'number of columns in the data']);
end
for i = 1:ne
if isempty(o.table_data{1}.column_names) ||isempty(o.table_data{1}.column_names{i})
fprintf(fid, 'l');
else
fprintf(fid, 'r');
......@@ -216,14 +223,16 @@ if ~is_data_table
csvseries.save(strrep(o.tableName, '.tex', ''), 'csv');
end
else
fprintf(fid, '%%\n');
fprintf(fid, '\\hline%%\n');
fprintf(fid, '%%\n');
for i = 1:length(o.column_names)
if ~isempty(o.column_names{i})
fprintf(fid, '%s', o.column_names{i});
if ~isempty(o.table_data{1}.column_names)
fprintf(fid, '%%\n');
fprintf(fid, '\\hline%%\n');
fprintf(fid, '%%\n');
end
for i = 1:ne
if ~isempty(o.table_data{1}.column_names) && ~isempty(o.table_data{1}.column_names{i})
fprintf(fid, '%s', o.table_data{1}.column_names{i});
end
if i ~= length(o.column_names)
if i ~= ne
fprintf(fid, ' & ');
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment