A=zeros(n);
A
%row 1
i=1;
A(i,i)=1;
A(i,i+1)=-1;
A
%intermediate rows i=2 to n-1
for i=2:n-1
    A(i,i-1)=i-1;
    A(i,i)=-(2*i-1);
    A(i,i+1)=i;
end
A
% last row
i=n;
A(i,i)=1;
A
