MATLAB: How to delete some rows of a matrix

matricesmatrixmatrix manipulation

Hi. Suppose I have matrix A e.g.
A=[8.2505 4.8825 2.2563 0.0020 0
8.2505 4.8825 2.2687 0.0020 1
8.2505 4.8825 2.2813 0.0020 2
8.2505 4.9325 2.2813 0.0020 0
8.2505 4.9325 2.2938 0.0020 3
8.2755 4.7575 2.2437 0.0020 0
8.2755 4.7575 2.2563 0.0020 0
8.2755 4.7575 2.2687 0.0020 2
8.2755 4.8075 2.2188 0.0020 0
8.2755 4.8075 2.2313 0.0020 3
8.2755 4.8075 2.2437 0.0020 1
8.2755 4.8075 2.2563 0.0010 0
8.2755 4.8075 2.2687 0.0010 2];
I want to delete the rows that their fifth column values are unequal to 0 and at the end I want to have the new matrix A without these rows.
Thanks a lot.

Best Answer

A = A(A(:,5)==0,:);
or
A(A(:,5)~=0,:) = [];