MATLAB: Access Diagonal Matrix Element

diagonalmatrix manipulation

Hello,
I have matrix 15×60 dimension. How can I generate diagonal data?
If I use "diag" function, I only got matrix 15×1.
Thank you,
Ana

Best Answer

As it is a rectangular matrix you will get 15 diagonal(i=j) elements. If you have a square matrix of size nxn, you will get n diagonal elements.