Changeset 125 for trunk/src


Ignore:
Timestamp:
Nov 18, 2010, 11:21:23 PM (14 years ago)
Author:
gostiaux
Message:

code simplification;
Can still be upgraded using function char (see last comment line)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cell2tab.m

    r107 r125  
    1111function Tabchar=cell2tab(Tabcell,separator)
    1212Tabchar={};%default
    13 [nx,ny]=size(Tabcell);
    14 %determine width withcolumn(jtab) of each column
    15 for 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
    22 end
     13[ni,nj]=size(Tabcell);
     14
     15%determine width of each column
     16widthcolumn=max(cellfun(@length,Tabcell));
     17
    2318%justify table
    24 for itab=1:nx   
     19for itab=1:ni   
    2520    charchain=[];         
    26     for jtab=1:ny% read line
     21    for jtab=1:nj% read line
    2722        textlu=Tabcell{itab,jtab};
    2823        if widthcolumn(jtab)>length(textlu)
     
    3732    Tabchar(itab,1)={charchain};
    3833end
     34
     35%nb : char(Tabchar(:,jtab)) gives directly a column with the blanks filled
Note: See TracChangeset for help on using the changeset viewer.