MATLAB Answers

Poulomi
0

Removing rows of a matrix based on certain criteria

Asked by Poulomi
on 11 Dec 2014
Latest activity Answered by Matt J
on 11 Dec 2014
I have a matrix
A = [110 1 2 3 4;
111 11 12 15 16; 112 0 0 0 0;
113 9.43e+36 9.43e+36 9.43e+36 9.43e+36;
114 34 45 67 89].
I want to delete those rows, which contains elements 0 and 9.43e+36 from 2nd to end column of matrix A so that my resulting matrix should be
A = [110 1 2 3 4;
111 11 12 15 16;
114 34 45 67 89].

  0 Comments

Sign in to comment.

1 Answer

Answer by Matt J
on 11 Dec 2014
 Accepted Answer

idx=any(~A(:,2:end) | A(:,2:end)==9.43e+36,2);
A=A(~idx,:)

  0 Comments

Sign in to comment.