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

조회 수: 1 (최근 30일)
Karel Starý
Karel Starý 2021년 8월 2일
댓글: Peter Perkins 2021년 8월 6일
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.
Peter Perkins
Peter Perkins 2021년 8월 6일
glad to help. we all have our off days.

댓글을 달려면 로그인하십시오.

추가 답변 (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