# Math Help - matlab, diagonal of diagonal

1. ## matlab, diagonal of diagonal

what does
Code:
diag(A), diag(diag(B))
do?
I know that the first part takes the diagonal of matrix A and displays it as a vector, and the second part takes the result from the first part and does the same process again. But why for the second part it seems to criss cross the results?

2. Originally Posted by superdude
what does
Code:
diag(A), diag(diag(B))
do?
I know that the first part takes the diagonal of matrix A and displays it as a vector, and the second part takes the result from the first part and does the same process again. But why for the second part it seems to criss cross the results?
>help diag

CB