function y = blkdiag(...),
  ## Build a block-diagonal matrix from all the arguments
  ## Daniel Calvelo 2000. Use, modify and debug at will
  nin = 0;
  va_start();
  sizes = zeros( nargin, 2 );
  while( ++nin <= nargin ),
    m = va_arg();
    if ~isnumeric( m ),
      error("Non-numeric argument found.");
    endif
    sizes(nin,:) = size( m );
  endwhile
  csz = [[0 0];cumsum(sizes)]
  y = zeros( max(csz) );
  va_start();
  nin = 0;
  while(++nin <= nargin),
    y(csz(nin,1)+1:csz(nin+1,1) , csz(nin,2)+1:csz(nin+1,2)) = va_arg();
  endwhile
endfunction
