How to delete enitre row if the row contain matching string

조회 수: 2 (최근 30일)
Kanakaiah Jakkula
Kanakaiah Jakkula 2018년 2월 9일
댓글: Kanakaiah Jakkula 2018년 2월 10일
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에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by