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

1 次查看(过去 30 天)
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 个评论
dpb
dpb 2021-8-2
Make it easier -- attach the sample array as .mat file and tell us which column...I presume the selected one, but yoou don't say so...
Karel Starý
Karel Starý 2021-8-3
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:

请先登录,再进行评论。

采纳的回答

Peter Perkins
Peter Perkins 2021-8-3
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 个评论
Karel Starý
Karel Starý 2021-8-4
编辑:Karel Starý 2021-8-4
I cannot stress enough how dumb I feel right now. I finally realized how you meant it. String length should definitely work for me. Thank you for your effort.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by