source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/table.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.8 KB
Line 
1function table(superheader,header,data,formats)
2%TABLE Internal function to display tables
3
4% Author Johan Löfberg
5% $Id: table.m,v 1.2 2004/07/02 08:17:32 johanl Exp $
6
7
8  [nheadersy,nheadersx] = size(header);
9  [ndatay,ndatax] = size(data);
10 
11  datasizes = zeros(ndatay,ndatax);
12  for i = 1:ndatay
13    for j = 1:ndatax
14      if isa(data{i,j},'double')
15        data{i,j} = num2str(data{i,j});
16      end
17        datasizes(i,j) = length(data{i,j});
18    end
19  end
20 
21  headersizes = zeros(1,nheadersx);
22  for j = 1:nheadersx
23    if isa(header{j},'double')
24      header{j} = num2str(header{j});
25    end
26    headersizes(1,j) = length(header{j});
27  end
28 
29  if nargin<4
30    for i = 1:ndatax
31      formats{i}.header.just = 'right';
32      formats{i}.data.just = 'right';
33    end
34  end
35 
36  datawidth = sum(datasizes,2);
37 
38  MaxWidth = max([headersizes;datasizes]);
39  HeaderLine = ['|'];
40  for i = 1:nheadersx
41    HeaderLine = [HeaderLine ' ' strjust(fillstringRight(header{i},MaxWidth(i)+2),formats{i}.header.just) '|'];
42  end
43  HeaderLine = [HeaderLine ''];
44 
45  for j = 1:ndatay
46    DataLine{j} = ['|'];
47    for i = 1:ndatax
48      DataLine{j} = [DataLine{j} ' '  strjust(fillstringRight(data{j,i},MaxWidth(i)+2),formats{i}.data.just) '|'];
49    end
50  end
51  if ~isempty(superheader)
52    disp(char(repmat(double('+'),1,length(HeaderLine))))
53    disp(['|' strjust(fillstringLeft(superheader{1},length(HeaderLine)-2),'center') '|'])
54  end
55  disp(char(repmat(double('+'),1,length(HeaderLine))))
56  disp(HeaderLine)
57  disp(char(repmat(double('+'),1,length(HeaderLine))))
58  for i = 1:length(DataLine)
59    disp(DataLine{i});
60  end
61  disp(char(repmat(double('+'),1,length(HeaderLine))))
62 
63
64
65function x= truncstring(x,n)
66if length(x) > n
67        x = [x(1:n-3) '...'];
68end
69
70function x = fillstringLeft(x,n)
71x = [x blanks(n-length(x))];
72
73function x = fillstringRight(x,n)
74x = [blanks(n-length(x)) x];
75
76
77
Note: See TracBrowser for help on using the repository browser.