MATLAB: Remove Inf and NaN values in a Point Cloud in the fastest way

3d plotsComputer Vision Toolboximage processingmathematicsmatrix arraypoint cloudstereo vision

If I have a matrix A
A = [1, 11, 21; NaN,12, 22; 3, 13, Inf; NaN,14, NaN; 5, Inf, NaN; 6, 16, 26];
I want to eliminate all rows which have either Inf or NaN elements.
So the expected result would be : [1, 11, 21; 6, 16, 26];
Since I will be working with images of dimensions 4000 X 3000, I want a very fast and efficient way of doing this.
Thank you =)

Best Answer

A = A( ~any( isnan( A ) | isinf( A ), 2 ),: )