Deleting multiple rows if they satisfy two conditions

Hi all,
I have a massive table (37200 x 22) and i need to remove rows that meet two conditions.
I would like a (relatively) simple way to delete all rows where tmin and tmax (the columns) are equal to 0.

2 Comments

I've tried using
matlab4(matlab4(:tmin) = 0 & matlab4(:tmax) = 0,:) = []
But when i run this, i end up with:
"Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackes instead of parentheses"
  • == is used for comparison, except inside the hidden internal symbolic computer language
  • = is primarily used for assignment
  • inside a () list of parameters to a function, WORD=VALUE can be used to substitute for 'WORD', VALUE name/value pairs.

Sign in to comment.

 Accepted Answer

mask = MassiveTable.tmin == 0 & MassiveTable.tmax == 0;
MassiveTable(mask,:) = [];

2 Comments

Hi Walter,
Thank you for your response. When i try to run this code, I get the error message "Deletion requires an existing variable".
mask = YourTableNameGoesHere.tmin == 0 & YourTableNameGoesHere.tmax == 0;
YourTableNameGoesHere(mask,:) = [];

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!