n = 100
for i = 1:n
    for j = 1:n

        if i == j
            A(i,j) = 2;
        elseif abs(i-j) == 1
            A(i,j) =  -1;
        else
            A(i,j) = 0;
        end %if

    end % for j
end % for i 
A