-
Notifications
You must be signed in to change notification settings - Fork 8
/
printdistmat.m
executable file
·119 lines (105 loc) · 2.41 KB
/
printdistmat.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
function printdistmat(D,sbeNode,dec)
%PRINTMATRIX - Prints to the screen a printout of the matrix
%
% printmatrix(D,aln,dec)
% PRINTMATRIX prints to the screen a nice easy to read printout of the matrix D
% that can be copied and pasted into other applications (e.g. Excel).
%
% PRINTMATRIX(D); prints out the contents of D with 3 decimal places
%
% PRINTMATRIX(D,DEC); prints out the contents of D with DEC decimal places
%
%
% Written by Stephan W. Wegerich, SmartSignal Corp. August, 2001.
%
% if(nargin==1),dec=3;end
% [n,m]=size(sbeNode);
% for k=1:m
% fprintf(['%s\t'],char(sbeNode(n)));
% end
% fprintf('\n');
if(nargin<3),dec=3;end
if(nargin<2),sbeNode=strread(num2str(1:size(D,1)),'%s'); end
if(any(~isreal(D(:)))), error('Input Must be Real'); end
if(any(isnan(D(:))))
disp('Raw output shown because NaN in result.');
disp(' ');
disp(D);
return;
end
[N,M]=size(D);
D2=D; D2(D2==inf)=[];
ff=ceil(log10(max(max(abs(D2)))))+dec+3;
fprintf('\n');
symmetry='nodiag';
if ~(N==M)
symmetry='yes';
end
%symmetry='yes';
switch (symmetry)
case ('yes')
for i=1:N,
%name=char(sbeNode(i));
name=sbeNode{i};
[x,len]=size(name);
if (len>10)
len=10;
name = char(name(1:len));
elseif (len<10)
name(len+1:10)=' ';
end
fprintf(['%s '],name);
if (dec==0)
fprintf(['%#',num2str(ff),'d '],D(i,:));
else
fprintf(['%#',num2str(ff),'.',num2str(dec),'f '],D(i,:));
end
fprintf('\n');
end
case ('no')
for i=1:N,
name=sbeNode{i};
[x,len]=size(name);
if (len>10)
len=10;
name = char(name(1:len));
elseif (len<10)
name(len+1:10)=' ';
end
fprintf(['%s '],name);
if (i<=M)
for j=1:i,
if (dec==0)
fprintf(['%#',num2str(ff),'d '],D(i,j));
else
fprintf(['%#',num2str(ff),'.',num2str(dec),'f '],D(i,j));
end
end
end
fprintf('\n');
end
case ('nodiag')
for i=1:N,
name=sbeNode{i};
[x,len]=size(name);
if (len>10)
len=10;
name = char(name(1:len));
elseif (len<10)
name(len+1:10)=' ';
end
fprintf(['%s '],name);
if (i<=M)
for j=1:i,
if ~(i==j)
if (dec==0)
fprintf(['%#',num2str(ff),'d '],D(i,j));
else
fprintf(['%#',num2str(ff),'.',num2str(dec),'f '],D(i,j));
end
end
end
end
fprintf('\n');
end
end