source: trunk/src/cell2tab.m @ 114

Last change on this file since 114 was 107, checked in by sommeria, 14 years ago

aver_stat and time_series: bug repairs for reading images, for time series, the projection of images on a line now works
get_field: various bug repairs, export field on work space activated
struct2nc and struct2nc_toolbox.m: small bug repaired
nomtype2pair: test on string input introduced to avoid error
cell2tab: test on multiline input introduced
civ: pb about cell repair (bug with recent versions of matlab)

File size: 1.2 KB
Line 
1%'cell2tab': transform a Matlab cell in a character array suitable for display in a table
2%------------------------------------------------------------------------
3% function Tabchar=cell2tab(Tabcell,separator)
4%
5% OUTPUT:
6% Tabchar: character array suitable for table display
7%
8% INPUT:
9% Tabcell: (nx,ny) cell table, for nx lines separator: character used for separating displayed columns
10
11function Tabchar=cell2tab(Tabcell,separator)
12Tabchar={};%default
13[nx,ny]=size(Tabcell);
14%determine width withcolumn(jtab) of each column
15for jtab=1:ny
16    widthcolumn(jtab)=0;%default
17    for itab=1:nx% read line
18        if widthcolumn(jtab)<length(Tabcell{itab,jtab})
19            widthcolumn(jtab)=length(Tabcell{itab,jtab});
20        end
21    end
22end
23%justify table
24for itab=1:nx   
25    charchain=[];         
26    for jtab=1:ny% read line
27        textlu=Tabcell{itab,jtab};
28        if widthcolumn(jtab)>length(textlu)
29            blankstr=char(32*ones(1,widthcolumn(jtab)-length(textlu)));
30            textlu=[textlu blankstr];
31        end
32        if ~isempty(charchain)
33            textlu=[separator textlu];
34        end
35        charchain=[charchain textlu];
36    end
37    Tabchar(itab,1)={charchain};
38end
Note: See TracBrowser for help on using the repository browser.