source: trunk/src/cell2tab.m @ 19

Last change on this file since 19 was 19, checked in by gostiaux, 11 years ago

the private files have been moved down to the root folder

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