unioncell

PURPOSE ^

return a cell which is the union of cell B to cell A given by a comparing

SYNOPSIS ^

function AB=unioncell(A,colA,B,colB)

DESCRIPTION ^

return a cell which is the union of cell B to cell A given by a comparing
***the first n characters in the string of B, column B****

INPUT
A          cell array A
colA       column of A for comparison
B          cell array B
colB       column of B for comparison

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function AB=unioncell(A,colA,B,colB)
0002 %return a cell which is the union of cell B to cell A given by a comparing
0003 %***the first n characters in the string of B, column B****
0004 %
0005 %INPUT
0006 %A          cell array A
0007 %colA       column of A for comparison
0008 %B          cell array B
0009 %colB       column of B for comparison
0010 
0011 %OUTPUT
0012 %AB         cell which is the union of cell B to cell A
0013 
0014 %Ronan Fleming
0015 
0016 [rlt,clt]=size(A);
0017 [rlt2,clt2]=size(B);
0018 
0019 %preallocate cell
0020 AB=cell(rlt,clt+clt2);
0021 
0022 for r=1:rlt
0023     match=0;
0024     for r2=1:rlt2
0025         if strncmp(A{r,colA},B{r2,colB},length(B{r2,colB}))
0026             for c=1:clt
0027                 AB{r,c}=A{r,c};
0028             end
0029             for c2=1:clt2
0030                 AB{r,c+c2}=B{r2,c2};
0031             end
0032             match=1;
0033         else
0034             for c=1:clt
0035                 AB{r,c}=A{r,c};
0036             end
0037         end
0038     end
0039     if match==0
0040        fprintf('%s\n',['No match:  ' int2str(r) ' ' A{r,colA}]); 
0041     end
0042 end

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003