% m2_sparsity.m - playing with sparse matrices clf, clear all A = [1 2; 0 4] whos B = sparse(A) whos A = eye(100); B = speye(100); whos spy(A) spy(B) B(40:60,[10 20 40]) = 3; spy(B) spy(B+B') spy((B+B')^2) A = sprandsym(7,.25) full(A) A = sprandsym(10000,.002); spy(A) zoom(2), zoom(2),... zoom out A = A + 10*speye(10000); b = ones(10000,1); x = A\b; x = pcg(A,b); x = pcg(A,b,1e-12,200); norm(A*x-b) more on help sparfun A = gallery('wathen',20,20); spy(A) spy(A^2) spy(A^3)