# # function G=tabtoind (N) # # Computes the indicator matrix for a two-way contingency table # # Input: A two-way contingency table N, with A rows and B columns. # Output: The indicator matrix, of dimension [n,A+B] # function G=tabtoind (N) [A,B]=size(N); n=sum(sum(N)); G=zeros(n,A+B); nu=1; for i=1:A, for j=1:B, for k=1:N(i,j), G(nu,i)=1; G(nu,A+j)=1; nu++; end end end endfunction