-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlatexReport.m
78 lines (59 loc) · 1.67 KB
/
latexReport.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function [ ] = latexReport( out_name, errL2, errH1, h, nt, n, t)
fid = fopen(out_name,'wt');
doc_class = '\documentclass{standalone}';
fprintf(fid, '%s\n\n',doc_class);
begin_doc = '\begin{document}';
clearpage = '\clearpage';
fprintf(fid, '%s\n\n', begin_doc);
fprintf(fid, '%s\n', clearpage);
disp('[*] Writing Latex Table Report:');
fprintf('');
sh = 'h & $';
for i=1:n
sh = [sh, num2str(h(i))];
if (i==n)
sh = [sh, '$ \\ \hline'];
else
sh = [sh, '$ & $'];
end
end % end for i
for j=1:nt
fprintf(' - t = %s', num2str(t(j)));
sL2 = 'ErrL2 & $';
sH1 = 'ErrH1 & $';
for i=1:n
sL2 = [sL2, num2str(errL2(i,j))];
sH1 = [sH1, num2str(errH1(i,j))];
if (i==n)
sL2 = [sL2, '$ \\ \hline'];
sH1 = [sH1, '$ \\ \hline'];
else
sL2 = [sL2, '$ & $'];
sH1 = [sH1, '$ & $'];
end
end % end for i
% Used tmp variables to avoid problems with the escape character \,
% which is pervasive in Latex commands
hfill = '\hfill \\';
fprintf(fid, '%s \n',hfill);
begin_table = '\begin{table}[!h]';
centering = '\centering';
fprintf(fid, '%s\n%s\n', begin_table, centering);
begin_tabular = '\begin{tabular}{ | c | c | c | c | c | c | c | }';
fprintf(fid, '%s\n', begin_tabular);
h_line = '\hline';
fprintf(fid, '%s\n', h_line);
fprintf(fid, '%s\n', sh);
fprintf(fid, '%s\n', sL2);
fprintf(fid, '%s\n', sH1);
end_tabular = '\end{tabular}';
caption = '\caption{t = ';
end_table = '\end{table}';
fprintf(fid, '%s\n%s%s }\n%s\n\n', end_tabular, caption, num2str(t(j)), end_table);
fprintf(' ... OK \n');
end
fprintf(fid, '\n%s\n', clearpage);
end_doc = '\end{document}';
fprintf(fid, '\n\n%s', end_doc);
fclose(fid);
end