function B = repmat(A,M,N)
%REPMAT Replicate a matrix by factors of M and N.
%	B = REPMAT(A,M,N) replicates the matrix A to produce the
%	M-by-N block matrix B.
%	
%	Example:
%	    repmat(magic(2),2,3)

%	Copyright (c) 1995 by The MathWorks, Inc.
%	$Revision: 1.2 $  $Date: 1994/12/22 15:44:57 $

if nargin < 2
   error('Requires at least 2 inputs.')
elseif nargin == 2
   N = M;
end
[m,n] = size(A);
mind = (1:m)';
nind = (1:n)';
mind = mind(:,ones(1,M));
nind = nind(:,ones(1,N));
B = A(mind,nind);
