source: trunk/src/cell2tab.m @ 102

Last change on this file since 102 was 89, checked in by sommeria, 14 years ago

many bug corrections and cleaning. Activation of the BW option in uvmat. Improvement of the interaction of get_field with uvmat.

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)={charchain};
38    Tabchar(itab,1)={charchain};
39end
Note: See TracBrowser for help on using the repository browser.