I have two large matrices, matrix Z and matrix H, both 121x962. In matrix Z I removed values below a desired threshold and left NaN in place of those elements, so the size of the matrix did not change. In matrix H, I want to remove the values that are in the corresponding position as those labelled NaN in matrix Z.
For example, in matrix Z I have elements [1,2], [50,7], [40,32], [113,6] etc. labelled as NaN. I want to remove these same elements ([1,2], [50,7], [40,32], [113,6] etc.) from matrix H. Is there a way to specify that I want to remove all the elements labelled NaN in Z from matrix H without having to provide the exact coordinates I want to remove.