How to create new cell array from a cell array that meets a condition?
5 ビュー (過去 30 日間)
古いコメントを表示
Athby Al-Tawhid
2022 年 12 月 22 日
回答済み: Walter Roberson
2022 年 12 月 22 日
I have a cell array that is 500x20 in size. The last column contains the string 'Good' or 'Bad'. I want to make a new cell array that has the rows that contain the 'Good' string in the last column. For example:
1 6 4 8 Bad
3 8 5 3 Good
a= 8 6 4 9 Bad
7 4 3 6 Good
7 7 6 3 Bad
I want the output to be a new cell array with the second and fourth rows.
0 件のコメント
採用された回答
Walter Roberson
2022 年 12 月 22 日
mask = strcmp(YourCell(:,end), 'Good');
GoodRows = YourCell(mask,:);
Question: have you considered using a table() instead of a cell array? Also have you considered using categorical for the conditions ?
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!