MATLAB: Delete rows in a table

deleterowzero

Hi, I need help to delete several rows of a table whose column has a zeros for example
column 1 column2
1 2
3 2
4 0
5 6
1 0
9 0
I need delete the rows number 3,5 and 6

Best Answer

Assuming you indeed have a matlab table:
yourtable(yourtable.column2 == 0, :) = [];
will delete all rows whose column2 is 0.
If your table is actually a matrix:
yourmatrix(yourmatrix(:, 2) == 0, :) = [];
will do the same.