how to optimize a diag matrix with sparse

3 Ansichten (letzte 30 Tage)
Dimitrios
Dimitrios am 5 Jun. 2014
Beantwortet: James Tursa am 5 Jun. 2014
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)

Antworten (1)

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

Kategorien

Mehr zu Sparse Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by