forked from eukota-zz/matlab_loadflow_newton-raphson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
latexprint.m
38 lines (37 loc) · 876 Bytes
/
latexprint.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
%% mattex
% prints matrix ready for LaTeX tabular environment
%% INPUTS
% * *mat*: matrix to print
% * *style*: defaults to matrix with & and //, 1 eliminates &, 2 eliminates & and //
function latexprint(mat,style)
if(nargin<2)
style=0;
end
[r,c]=size(mat);
for(i=1:r)
num=nearzero(mat(i,1));
if(num==0)
fprintf('%d',num);
else
fprintf('%f',num);
end
for(j=2:c)
if(style==1 || style==2)
fprintf(' ');
else
fprintf(' & ');
end
num=nearzero(mat(i,j));
if(num==0)
fprintf('%d',num);
else
fprintf('%f',num);
end
end
if(style==2)
fprintf('\n');
else
fprintf('\\\\\n');
end
end
end