필터 지우기
필터 지우기

how to delete rows that have string in file?

조회 수: 2 (최근 30일)
Sonisa
Sonisa 2016년 1월 12일
댓글: Sonisa 2016년 1월 12일
I want to delete the rows after the date. I tried using data(strcmp(data(:,1), 'END'), :) = [];. My data is 9*23 cell file. Can anyone tell me how to do in a loop?
'5/18/2015'
'END'
'ERROR(s) Encountered:'
''
'Check calibration'
'MVOR - Up or Down Sensor MilliVolt Over-Range value encountered!'
'Check gain adjustments or incident light conditions.'
''
'Check DLC DATE'

채택된 답변

Walter Roberson
Walter Roberson 2016년 1월 12일
data( find(strcmp(data(:,1), 'END'), 1, 'first'):end, :) = [];

추가 답변 (1개)

Sonisa
Sonisa 2016년 1월 12일
This is not working. I have attached a screenshot of my work. I want to delete after the date in each cell. For eg. in {1,1} cell there is 365*1 cell and I need data until the date.
Hope the screenshot will help.
Thanks again
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 1월 12일
It works fine for me on your sample data.
data = {'5/18/2015'
'END'
'ERROR(s) Encountered:'
''
'Check calibration'
'MVOR - Up or Down Sensor MilliVolt Over-Range value encountered!'
'Check gain adjustments or incident light conditions.'
''
'Check DLC DATE'
};
data( find(strcmp(data(:,1), 'END'), 1, 'first'):end, :) = [];
This leaves data as {'5/18/2015'}
Sonisa
Sonisa 2016년 1월 12일
Thank you. It works finally.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by