How can one use the for loop and conditional execution commands to extract elements in the leading diagonal in a matrix?