What you say makes no sense. If you have a full matrix already, and you are turning that into a sparse matrix, then you would just use the function sparse to make it sparse. As such, the indices of that matrix will not be negative, since the matrix already exists. So that means you are not doing what you said you are doing.
Instead, it looks like you are creating a matrix from some formula for the elements of a matrix, and at the boundary of that problem, your formula creates some zero or negative indices. Now you have a situation where you are confused, since MATLAB does not allow matrices with a negative or zero index. So MATLAB generates an error, telling you that you cannot have zero or negative indices into a matrix.
That means in turn, you need to understand what to do at that boundary. This typically involves the formulation of a boundary condition, so a different formula for the problem at the boundary. That is a classic issue in mathematics when you are solving problems of this sort, but it is not just an issue of MATLAB. It comes into play whenever you are solving any such problem in any language, because a matrix is a finite thing. It has a boundary. In fact, this happens even for more general mathematical problems, thus PDEs, boundary value problems. You need to understand how to formulate that boundary in terms of mathematics.
Finally, it may sometimes force you to use an offset index, recognizing that MATLAB uses an index origin of ONE for its matrices.