shifting the elements of matrix

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]

2 Comments

A_original = ...?
I have attached here.

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 23 Apr 2017
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

Can u give me one example of this command.
kritika - this seems like homework so please try to use triu and reply back with any error that you are observing.

Sign in to comment.

Categories

Asked:

on 23 Apr 2017

Commented:

on 23 Apr 2017

Community Treasure Hunt

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

Start Hunting!