How to delete enitre row if the row contain matching string

5 次查看(过去 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

采纳的回答

Kai Domhardt
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,:) = [];
If you are interested in performance this might be interesting.
  1 个评论
Kanakaiah Jakkula
Kanakaiah Jakkula 2018-2-10
Sir, I use this function, but its too slower, any other function? I even use ismember. Looking for any other function to enhance execution time.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multicore Processor Targets 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by