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