how to optimize a diag matrix with sparse

3 次查看(过去 30 天)
How to optimize this diagonal matrix using sparse :
a=diag([-ones(9,1)],-1)+diag([ones(10,1)])+diag([0 ones(1,4) 0],4)

回答(1 个)

James Tursa
James Tursa 2014-6-5
If you mean how to create the equivalent sparse matrix to your full matrix shown, try using the spdiags function instead of diag.

类别

Help CenterFile Exchange 中查找有关 Sparse Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by