How to delete enitre row if the row contain matching string

3 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Kai Domhardt
Kai Domhardt il 9 Feb 2018
Modificato: Kai Domhardt il 9 Feb 2018
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 Commento
Kanakaiah Jakkula
Kanakaiah Jakkula il 10 Feb 2018
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Multicore Processor Targets in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by