Create sparse matrix with zig-zag diagonal
Ältere Kommentare anzeigen
Is there a way to shift every column c by (c-1)*n rows down, where n is size(A,1) in the following example, without a loop and without excessive memory usage? So to get
A = [
a11 a12 a13 a14 ...
a21 a22 a23 a24 ...
... ... ... ... ...
]
to read
B = [
a11 0 0 0 ...
a21 0 0 0 ...
... ... ... ... ...
0 a12 0 0 ...
0 a22 0 0 ...
... ... ... ... ...
0 0 a13 0 ...
0 0 a23 0 ...
... ... ... ... ...
0 0 0 a14 ...
0 0 0 a24 ...
... ... ... ... ...
]
I tried diag and sparse with no luck so far. I need Matrix A in an operation X=J\A afterwards. It is crucial that the zero elements do not consume memory as A can have up to 20e6 columns and probably 10 rows.
Thanks in advance.
Akzeptierte Antwort
Weitere Antworten (1)
Kategorien
Mehr zu Sparse Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!