function out=rjextendmat(X);
% RJEXTENDMAT(X)
%    Given a (m x n) matrix X, RJEXTENDMAT returns a new matrix
%    of dimensions (m+2 x n+2). Currently the extensions are linear.
%    The extra corner values are put to zero currently (net expected to
%    be used). This function is called from rjsurfacenormal.m


s1=size(X,1);
s2=size(X,2);
firstcol=2*X(:,1)-X(:,2);
lastcol=2*X(:,s2)-X(:,s2-1);
firstrow=2*X(1,:)-X(2,:);
lastrow=2*X(s1,:)-X(s1-1,:);

%The corner extensions - not intending to use them - just setting them to
%zero for now.

leftup=0;
rightup=0;
leftdown=0;
rightdown=0;

out=[leftup firstrow rightup;firstcol X lastcol;leftdown lastrow rightdown];


