21 lines
No EOL
288 B
Matlab
21 lines
No EOL
288 B
Matlab
n = 5;
|
|
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(n,n) = 0;
|
|
|
|
A = A + diag(n:(2*n-1));
|
|
spy(A);
|
|
matlab2tikz('../ex2_2_spy.tex');
|
|
|
|
figure;
|
|
subplot(1,2,1)
|
|
spy(A);
|
|
subplot(1,2,2)
|
|
spy(chol(A));
|
|
matlab2tikz('../ex2_3_spy.tex'); |