I have 8×8 matrix where I have 15 diagonals. upper left corner “diagonal 1” and the lower
right corner “diagonal 15”. I want to zero out the specific sets of diagonals like {9, 10, 11, 12, 13, 14, 15} or {5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}. Anyone please give me solution?
I have 8×8 matrix where I have 15 diagonals. upper left corner diagonal 1
Share
I believe you can use:
where k is 0 for the main diagonal, negative for the lower diagonals (up to -7), positive for the upper diagonals (up to 7).
EDIT: My bad, this only zero out one of the diagonal of your choice. You can repeat the process for all the diagonals you want to zero out but that might not be optimal: