This repository has been archived on 2021-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
NC/mp2/Project_2_Maggioni_Claudio/ex2.m
2020-10-21 15:21:51 +02:00

27 lines
350 B
Matlab

A = createA(5);
spy(A);
matlab2tikz('../ex2_2_spy.tex');
A = createA(100);
figure;
subplot(1,2,1)
spy(A);
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