1 function print_datatable(fname, title, values, blocksize)
2 %
function print_datatable(fname, title, values, blocksize)
4 % print a matrix in a tabulator separated table stored in file
'fname'. This
5 % can be used by all pgfplots commandos in LaTeX.
8 %
'fname': file name of file where the table is stored
9 %
'title': vector of column titles
10 %
'values': matrix or 2d-cell array whose rows are written to the table
11 %
'blocksize': separate blocksize values with a
new line in each column,
12 % needed
for patch plots
16 blocksize = size(values,2);
19 numblocks = size(values,2)/blocksize;
21 assert(numblocks-floor(numblocks)==0);
25 assert(length(title) == size(values, 1));
27 fpstring = [repmat(
'%s\t', 1, length(title)),
'\n'];
28 fprintf(fid, fpstring, title{:});
30 fpstring2 = cellfun(@formatter, values(:,1) , 'UniformOutput', false);
31 fpstring2 = [fpstring2{:},
'\n'];
33 fpstring2 = [repmat(
'%e\t', 1, length(title)),
'\n'];
37 fprintf(fid, fpstring2, values{:,(i-1)*blocksize+(1:blocksize)});
39 fprintf(fid, fpstring2, values(:,(i-1)*blocksize+(1:blocksize)));
48 function ft = formatter(value)
53 elseif islogical(value)
56 error('Do not know how to print out the values in cell array...');