Transform a matrix in a special way
Ältere Kommentare anzeigen
Hi !
I have this kind of matrix :
A=[1 2 3 4 5 6 7 8 9 10]
And I would like to transform it in this way:
B=[0 1 2 3 4 ; 0 0 5 6 7 ; 0 0 0 8 9 ; 0 0 0 0 10 ; 0 0 0 0 0]
I am looking for a simple method to do it, may you help me please ?
Akzeptierte Antwort
Weitere Antworten (1)
Fangjun Jiang
am 10 Feb. 2021
B=zeros(5);
B(tril(true(5),-1))=A
B=B'
Kategorien
Mehr zu Creating and Concatenating 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!