shifting the elements of matrix
Show older comments
Is there any command to shift diagonal of a matrix. I have attached my matrix here.So from my matrix I want a new matrix as
A_new=[ 1 0 0 0;
5 6 0 0;
9 10 11 0;
13 14 15 16;
0 2 3 4;
0 0 7 8;
0 0 0 12]
Answers (1)
Geoff Hayes
on 23 Apr 2017
0 votes
kritika - you could try to use triu which will return the upper triangular part of the matrix which you could then use to update the first three and last three rows of your A matrix.
2 Comments
kritika adhikari
on 23 Apr 2017
Geoff Hayes
on 23 Apr 2017
kritika - this seems like homework so please try to use triu and reply back with any error that you are observing.
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!