Removing elements in one matrix with same position as those in another matrix in matlab

1 view (last 30 days)
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.

Accepted Answer

madhan ravi
madhan ravi on 18 Sep 2020
H(isnan(Z)) = nan

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!