MATLAB: Table, delete columns with zero

tablezeros

I have a table with many rows and columns. How can I delete a column if any row contains zero? (I found a million ways to delete rows, but not columns, when dealing with tables.)

Best Answer

Got it; it takes two steps. First repalce zeros with NaN, then can clean it up:
table2 = standardizeMissing(table1, 0); % the 0 is the value to be replaced with NaN
table2 = rmmissing(table2, 2); % the 2 is for deleting rows; use 1 to delete columns