How to delete enitre row if the row contain matching string
2 次查看(过去 30 天)
显示 更早的评论
Hi, I have below cell matrix, and I want to remove(delete) entire row if column 3 or column4 contain NANA.
Input:
Item Identity PreName PostName hight weight date
AA1 Petrol 2 Raj 23 45 2018/02/09
AA1 Petrol 4 Hist 63 89 2018/02/09
AA2 Petrol NANA KLA 23 45 2018/02/09
AA2 Petrol BAN KAH 71 67 2018/02/09
SAA Gas TAH Forst 9 34 2018/02/09
SA4 Gas Lul NANA 53 95.3 2018/02/09
SA4 Tele JAYK YAHH 2.9 11.9 2018/02/09
SH7 Tele NANA NANA 15.3 3.3 2018/02/09
SP2 Tele FAG 8 123 100 2018/02/09
SP2 Tele 3 18 123 100 2018/02/09
Output:
Item Identity PreName PostName hight weight date
AA1 Petrol 2 Raj 23 45 2018/02/09
AA1 Petrol 4 Hist 63 89 2018/02/09
AA2 Petrol BAN KAH 71 67 2018/02/09
SAA Gas TAH Forst 9 34 2018/02/09
SA4 Tele JAYK YAHH 2.9 11.9 2018/02/09
SP2 Tele FAG 8 123 100 2018/02/09
SP2 Tele 3 18 123 100 2018/02/09
0 个评论
采纳的回答
Kai Domhardt
2018-2-9
编辑:Kai Domhardt
2018-2-9
Quick answer:
to_delete = (strcmp(data(:,3),'NANA') | strcmp(data(:,4),'NANA'));
data(to_delete,:) = [];
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!