function [] = tex_table(matrix,columnlabel,rowlabel)

if nargin<3, rowlabel=[];end
if nargin<2, columnlabel=[];end
%%
[nrows ncols]=size(matrix);
colms='';
for i=1:size(matrix,2)
    colms=sprintf('%sc',colms);
end
if ~isempty(rowlabel)
    for i=1:length(columnlabel)-size(matrix,2)
        colms=sprintf('c|%s',colms);
    end
end

fprintf('\\begin{table}[h]\n \\begin{center}\n \\begin{tabular}{|%s|}\n \\hline \n',colms)
if isa(columnlabel,'double')
    fprintf(' %g &',columnlabel(1:end-1))
    fprintf(' %g \\\\ \n \\hline \n',columnlabel(end));
else
    fprintf(' %s &',columnlabel{1:end-1})
    fprintf(' %s \\\\ \n \\hline \n',columnlabel{end});
end

for i=1:nrows
    if ~isempty(rowlabel)
        if isa(rowlabel,'double')
            fprintf(' %g &',rowlabel(i));
        else
            fprintf(' %s &',rowlabel{i});
        end
    end
    fprintf('%01.1e &',matrix(i,1:end-1));
    fprintf(' %01.1e \\\\ \n',matrix(i,end));
end
fprintf(' \\hline \n')
fprintf('\\hline \n\\end{tabular} \n\\end{center}\n \\caption{ENTER CAPTION HERE} \n\\label{tab:} \n \\end{table} \n\n')

