Use spdiagm
or BandedMatrices.jl (the former is generic to any sparse matrix, analogous to Matlab sparse matrices; the latter is specialized for banded matrices and can be more efficient for that particular structure)
2 Likes