comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/som_table_struct.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function sTable = som_table_struct(values,headers,span,colfmt)
2
3 %SOM_TABLE_STRUCT Create a table struct.
4 %
5 % sTable = som_table_struct(values,[headers],[span],[colfmt])
6 %
7 % Input and output arguments ([]'s are optional):
8 % values (cell array) size nrow x ncol, the contents of the table
9 % (char array) size nrow x *
10 % (matrix) size nrow x ncol
11 % [headers] (cell array) size 1 x ncol, header row of the table
12 % (empty) by default, empty headers are used ('')
13 % [span] (matrix) size nrow x ncol x 2, span of each cell of the
14 % table: span(:,:,1) gives horizontal span and
15 % span(:,:,2) gives vertical span. If the value
16 % for a cell is greater than 1, it should be
17 % followed by a corresponding number of zeros
18 % for the following cells (left or down)
19 % (empty) by default ones(nrow,ncol,1)
20 % [colfmt] (string) the format of each column as given in LaTeX,
21 % only used if the table is printed as 'ps' or 'pdf',
22 % by default colfmt = ''
23 %
24 % sTable (struct) the table struct, with the following fields:
25 % .headers (cell array) header row, size 1 x ncol
26 % .values (cell array) values, size nrow x ncol
27 % .span (matrix) span of each cell, size nrow x ncol x 2
28 %
29 % See also SOM_TABLE_MODIFY, SOM_TABLE_PRINT.
30
31 % Contributed to SOM Toolbox 2.0, December 31st, 2001 by Juha Vesanto
32 % Copyright (c) by Juha Vesanto
33 % http://www.cis.hut.fi/projects/somtoolbox/
34
35 % Version 2.0beta juuso 311201
36
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38
39 if ischar(values), values = cellstr(values);
40 elseif isnumeric(values), values = num2cell(values);
41 end
42 [nrow,ncol] = size(values);
43
44 if nargin<2 | isempty(headers), headers = cell(1,ncol); headers(:) = {''}; end
45 if ischar(headers), headers = cellstr(headers); end
46
47 if nargin<3 | isempty(span), span = ones(nrow,ncol,2); end
48 if sum(span(:)) > 2*nrow*ncol,
49 warning('span matrix has overlapping cells')
50 elseif sum(span(:)) < 2*nrow*ncol,
51 warning('span matrix has noncontinuous cells')
52 end
53
54 if nargin<4 | isempty(colfmt), colfmt = ''; end
55
56 sTable = struct('colfmt','','headers',[],'values',[],'span',[]);
57 sTable.colfmt = colfmt;
58 sTable.headers = headers;
59 sTable.span = span;
60 sTable.values = values;
61
62 return;
63
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%