필터 지우기
필터 지우기

I want to delete some lines from a .txt file

조회 수: 3 (최근 30일)
RANJITHA H V
RANJITHA H V 2016년 4월 12일
편집: Azzi Abdelmalek 2016년 4월 12일
I WANT TO REMOVE LINES WHICH CONTAINS CHARACTERS AND ALPHABETS AND I WANT TO RETAIN ONLY NUMBERS IN A TEXT DOCUMENT USING MATLAB. SOME ONE PLEASE HEP ME IN DOING SO. In the above text file, there are some lines like 'HUMAN DETECTED' 'Animal Detected'. I want to create a new file which contains only numbers and not these lines containing alphabetic messages.
  댓글 수: 2
KSSV
KSSV 2016년 4월 12일
where is the text file?
RANJITHA H V
RANJITHA H V 2016년 4월 12일
here there is attached file. please find the attachment.

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

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 12일
line='I want to delete 123 lines from 24 .txt file 0.458 and67.45'
out=regexp(line,'\d+(\.)?\d+','match')

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 12일
편집: Azzi Abdelmalek 2016년 4월 12일
fid=fopen('12-04-16-10-01-16.txt')
M=textscan(fid,repmat('%f ',1,16))
fclose(fid)
out=cell2mat(M)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by