function mat = insertMatrix(mat1,mat2,row,col)
%function mat = insertMatrix(mat1,mat2,[row],[col])
%
%Inserts matrix mat2 in to matrix mat1 with upper left corner of mat2
%determined by vectors row and col.  By default, row =1, and col = 2 (upper left).

%Written by GMB, University of Washington, October 2009

%Deal with default values for 'row' and 'col'
if ~exist('row')
    row = 1;
end

if ~exist('col')
    col = 1;
end

mat = mat1;

for i=1:length(row)
    mat(row(i):(row(i)+size(mat2,1)-1),col(i):(col(i)+size(mat2,2)-1)) = mat2;
end




