MATLAB Answers

Delete rows in cell aray where there is anything in one collum.

1 view (last 30 days)
I have multiple cell arrays and I would like to delete whole rows based on one particular column, if there is anything (text or number) in this column.
Thanks!
  2 Comments
Karel Starý
Karel Starý on 3 Aug 2021
Thanks for looking at my question!
You are right, it's the selected one. In this case the name of the variable is EventLTEEvents. Here you have my sample table:

Sign in to comment.

Accepted Answer

Peter Perkins
Peter Perkins on 3 Aug 2021
A cell array is the wrong way to store these data. You want a table, or probably a timetable. The fact that you say, "the name of the variable is EventLTEEvents" makes me wonder if you already have that. And I recommend that you store text in those tables as string, not as cell arrays of char rows.
Once you have that, deleting rows based on a condition is just subscripting, e.g.
T(T.X > 10,:) = []
In your case, the condition is probably something like strlength(T.EventLTEEvents) > 0.
  4 Comments

Sign in to comment.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!