Daniel@0: function sTable = som_table_struct(values,headers,span,colfmt) Daniel@0: Daniel@0: %SOM_TABLE_STRUCT Create a table struct. Daniel@0: % Daniel@0: % sTable = som_table_struct(values,[headers],[span],[colfmt]) Daniel@0: % Daniel@0: % Input and output arguments ([]'s are optional): Daniel@0: % values (cell array) size nrow x ncol, the contents of the table Daniel@0: % (char array) size nrow x * Daniel@0: % (matrix) size nrow x ncol Daniel@0: % [headers] (cell array) size 1 x ncol, header row of the table Daniel@0: % (empty) by default, empty headers are used ('') Daniel@0: % [span] (matrix) size nrow x ncol x 2, span of each cell of the Daniel@0: % table: span(:,:,1) gives horizontal span and Daniel@0: % span(:,:,2) gives vertical span. If the value Daniel@0: % for a cell is greater than 1, it should be Daniel@0: % followed by a corresponding number of zeros Daniel@0: % for the following cells (left or down) Daniel@0: % (empty) by default ones(nrow,ncol,1) Daniel@0: % [colfmt] (string) the format of each column as given in LaTeX, Daniel@0: % only used if the table is printed as 'ps' or 'pdf', Daniel@0: % by default colfmt = '' Daniel@0: % Daniel@0: % sTable (struct) the table struct, with the following fields: Daniel@0: % .headers (cell array) header row, size 1 x ncol Daniel@0: % .values (cell array) values, size nrow x ncol Daniel@0: % .span (matrix) span of each cell, size nrow x ncol x 2 Daniel@0: % Daniel@0: % See also SOM_TABLE_MODIFY, SOM_TABLE_PRINT. Daniel@0: Daniel@0: % Contributed to SOM Toolbox 2.0, December 31st, 2001 by Juha Vesanto Daniel@0: % Copyright (c) by Juha Vesanto Daniel@0: % http://www.cis.hut.fi/projects/somtoolbox/ Daniel@0: Daniel@0: % Version 2.0beta juuso 311201 Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: if ischar(values), values = cellstr(values); Daniel@0: elseif isnumeric(values), values = num2cell(values); Daniel@0: end Daniel@0: [nrow,ncol] = size(values); Daniel@0: Daniel@0: if nargin<2 | isempty(headers), headers = cell(1,ncol); headers(:) = {''}; end Daniel@0: if ischar(headers), headers = cellstr(headers); end Daniel@0: Daniel@0: if nargin<3 | isempty(span), span = ones(nrow,ncol,2); end Daniel@0: if sum(span(:)) > 2*nrow*ncol, Daniel@0: warning('span matrix has overlapping cells') Daniel@0: elseif sum(span(:)) < 2*nrow*ncol, Daniel@0: warning('span matrix has noncontinuous cells') Daniel@0: end Daniel@0: Daniel@0: if nargin<4 | isempty(colfmt), colfmt = ''; end Daniel@0: Daniel@0: sTable = struct('colfmt','','headers',[],'values',[],'span',[]); Daniel@0: sTable.colfmt = colfmt; Daniel@0: sTable.headers = headers; Daniel@0: sTable.span = span; Daniel@0: sTable.values = values; Daniel@0: Daniel@0: return; Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%