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