-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtab_param.m
executable file
·31 lines (30 loc) · 929 Bytes
/
tab_param.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function tex=tab_param(names,varargin)
% create a tex table of the parameters
paramvalues=varargin;
paramnames=cellfun(@inputname,num2cell(2:nargin),'UniformOutput',false);
header=sprintf([...
'\\begin{table}\n'...
' \\centering\n'...
' \\begin{tabular}{%s}\n'...
' \\hline\n'...
' & %s\\\\\n'...
' \\hline\n'...
],...
repmat('l',[1,1+numel(names)]),...
strjoin(names,' & ')...
);
content='';
for n=1:nargin-1
content=sprintf('%s %s & %s\\\\\n',...
content, ...
paramnames{n},...
strjoin(arrayfun(@(x)sprintf('%g',x),paramvalues{n},'UniformOutput',false),' & ')...
);
end
footer=sprintf([...
' \\hline\n'...
' \\end{tabular}\n'...
'\\end{table}\n'...
]);
tex=sprintf('%s%s%s',header,content,footer);
end