function weightedmat=weighted_neighbor_averaging(startmat,weighter)
%description: takes an input array and a two-element vector giving weight values for neighbors
    %uses these values to compute the new value for each point
    %should work with any non-zero size array
    %weighter gives the values for adjacent locations, l/r/u/d is the first value and at corners is second
%called by: snp_plotter
%calls: no custom functions
%code confirmed date:9 july 2014
    
    ulcorner=(startmat(1,1)+weighter(1)*startmat(2,1)+weighter(1)*startmat(1,2)+weighter(2)*startmat(2,2))/4;
    urcorner=(startmat(1,end)+weighter(1)*startmat(1,end-1)+weighter(1)*startmat(2,end)+weighter(2)*startmat(2,end-1))/4;
    llcorner=(startmat(end,1)+weighter(1)*startmat(end-1,1)+weighter(1)*startmat(end,2)+weighter(2)*startmat(end-1,2))/4;
    lrcorner=(startmat(end,end)+weighter(1)*startmat(end,end-1)+weighter(1)*startmat(end-1,end)+weighter(2)*startmat(end-1,end-1))/4;
    
    leftedge=(startmat(2:end-1,1)+weighter(1)*startmat(1:end-2,1)+weighter(1)*startmat(3:end,1)+weighter(1)*startmat(2:end-1,2)+weighter(2)*startmat(1:end-2,2)+weighter(2)*startmat(3:end,2))/6;
    rightedge=(startmat(2:end-1,end)+weighter(1)*startmat(1:end-2,end)+weighter(1)*startmat(3:end,end)+weighter(1)*startmat(2:end-1,end-1)+weighter(2)*startmat(1:end-2,end-1)+weighter(2)*startmat(3:end,end-1))/6;
    topedge=(startmat(1,2:end-1)+weighter(1)*startmat(1,1:end-2)+weighter(1)*startmat(1,3:end)+weighter(1)*startmat(2,2:end-1)+weighter(2)*startmat(2,1:end-2)+weighter(2)*startmat(2,3:end))/6;
    bottomedge=(startmat(end,2:end-1)+weighter(1)*startmat(end,1:end-2)+weighter(1)*startmat(end,3:end)+weighter(1)*startmat(end-1,2:end-1)+weighter(2)*startmat(end-1,1:end-2)+weighter(2)*startmat(end-1,3:end))/6;
    
    strippedmat=startmat(2:end-1,2:end-1);
    lmat=startmat(2:end-1,1:end-2);
    rmat=startmat(2:end-1,3:end);
    umat=startmat(1:end-2,2:end-1);
    dmat=startmat(3:end,2:end-1);
    ulmat=startmat(1:end-2,1:end-2);
    urmat=startmat(1:end-2,3:end);
    dlmat=startmat(3:end,1:end-2);
    drmat=startmat(3:end,3:end);
    
    centralmat=(strippedmat+weighter(1)*(lmat+rmat+umat+dmat)+weighter(2)*(ulmat+urmat+dlmat+drmat))/9;
    
    topweight=[ulcorner topedge urcorner];
    centralweight=[leftedge centralmat rightedge];
    bottomweight=[llcorner bottomedge lrcorner];
    
    weightedmat=[topweight;centralweight;bottomweight];
    
    
    