annotate toolboxes/MIRtoolbox1.3.2/somtoolbox/som_table_struct.m @ 0:cc4b1211e677 tip

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