%function table(labels,header,values,precision);
function t=table(labels,header,values,precision);
if ~iscell(labels);
    labels=str2cell(labels);
end
if ~iscell(header);
    header=str2cell(header);
end
labels=labels(:);
header=header(:);
ns=size(values);
nss=size(labels,1);
if ns(1)~=nss
    disp('#labels not equal # rows');
    return
end
nh=size(header,1);
if nh~=ns(2)
    disp('#headers not equal # columns (give headers only for data)');
    return
end
if nargin<4;
    precision=5;
end
gg=[];
space=[];
for jj=1:precision;
    space=[space,' '];
end
for jj=1:ns(2);
    
    gg=[gg,strvcat(header{jj},num2str(values(:,jj),precision)),repmat(space,ns(1)+1,1);];
end
        t=[strvcat('categories',strvcat(labels)),repmat('   ',ns(1)+1,1),gg];
disp(t)

return