function M = NeumannMatrix1(N,L)

% with Neumann boundary conditions, doing a two-point stencil to approximate
% the u_x at the left-hand and right-hand endpoints.  This changes the first row
% to [-1, 1, zeros] and the last row to [zeros, 1, -1]

h = L/N;
M = -2*eye(N-1);
for j=1:N-2
  M(j,j+1)=1;
end
for j=2:N-1
  M(j,j-1)=1;
end
M(1,1) = -1;
M(N-1,N-1) = -1;
M = M/h^2;
