Home > . > table.m

table

PURPOSE ^

Copyright (C) 2002 Michel Juillard

SYNOPSIS ^

function table(title,headers,labels,values,label_width,val_width,val_precis)

DESCRIPTION ^

 Copyright (C) 2002 Michel Juillard

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Copyright (C) 2002 Michel Juillard
0002 %
0003 function table(title,headers,labels,values,label_width,val_width, ...
0004            val_precis)
0005   label_width = max(size(deblank(strvcat(headers(1,:),labels)),2)+2, ...
0006             label_width);
0007   val_width = max(size(deblank(headers(2:end,:)),2)+2,val_width);
0008   label_fmt = sprintf('%%-%ds',label_width);
0009   header_fmt = sprintf('%%-%ds',val_width);
0010   val_fmt = sprintf('%%%d.%df',val_width,val_precis);
0011   if length(title) > 0
0012     disp(sprintf('\n\n%s\n',title));
0013   end
0014   if length(headers) > 0
0015     hh = sprintf(label_fmt,headers(1,:));
0016     hh = [hh char(32*ones(1,floor(val_width/4)))];
0017     for i=2:size(headers,1)
0018       hh = [hh sprintf(header_fmt,headers(i,:))];
0019     end
0020     disp(hh);
0021   end
0022   for i=1:size(values,1)
0023     disp([sprintf(label_fmt,labels(i,:)) sprintf(val_fmt,values(i,:))]);
0024   end
0025   
0026 % 10/30/02 MJ

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003