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. Related SolutionsMATLAB: Table, delete columns with zero 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 NaNtable2 = rmmissing(table2, 2); % the 2 is for deleting rows; use 1 to delete columns MATLAB: Keep specific column variables and delete others Var1 = {'Sanchez';'Johnson';'Li';'Diaz';'Brown'};Var2 = [38;43;38;40;49];Var3 = logical([1;0;1;0;1]);T = table(Var1,Var2,Var3)To keep columns one and three:T = [T(:,1) T(:,3)]T = 5×2 table Var1 Var3 _________ _____ 'Sanchez' true 'Johnson' false 'Li' true 'Diaz' false 'Brown' trueAdapt the code for columns 2 and 4. Related QuestionColumns of a matrixTable: how to extract rows that contain a certain string and put those values into a new columnGather many tables in one tableNeeds derivative w.r.t. ‘ y ‘ & then graph w.r.t ‘ t ‘Remove rows of a table based on values in an arrayDeleting rows of an array
Best Answer