A = createA(5);
spy(A);
matlab2tikz('../ex2_2_spy.tex');
A = createA(100);
figure;
subplot(1,2,1)
subplot(1,2,2)
spy(chol(A));
matlab2tikz('../ex2_3_spy.tex');
function A = createA(n)
A = sparse(n, n);
A(1,:) = 1;
A(end,:) = 1;
A(:,1) = 1;
A(:,end) = 1;
% make sure diagonal is 0
A(1,1) = 0;
A(end,end) = 0;
A = A + diag(n:(2*n-1));
end