Question

can you help me with this type of diagonal matrix?

  |      1| 
  |     1 |
  |    1  |
I=|   1   |
  |  1    |
  | 1     |
  |1      |

I don't know how to do it in Matlab.

Was it helpful?

Solution

You can use

fliplr(eye(7))

This results in

ans =

     0     0     0     0     1
     0     0     0     1     0
     0     0     1     0     0
     0     1     0     0     0
     1     0     0     0     0

OTHER TIPS

some more options (for the sake of completeness):

rot90(eye(7))

flipud(eye(7))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top