Using the Numpy matrix.diagonal ()
method, we can find the diagonal element
from the given matrix and output the result as a onedimensional matrix.
Syntax:
matrix.diagonal()
Return: Return diagonal element of a matrix
Example # 1:
In this example, we can see that using the matrix. diagonal ()
we can find elements on the diagonal of the matrix.

Output:
[[6 4]]
Example # 2:

Exit:
[[1 5 9]]