필터 지우기
필터 지우기

Hi. There a text file with many lines and my professor asked me to extract from this text file in a matrix just the lines which contains the word GPS10.he suggested me use fgetl and while lope. Could you please help me?

조회 수: 2 (최근 30일)
filename=uigetfile;
fid=fopen('sp3data.txt');

채택된 답변

KSSV
KSSV 2017년 11월 30일
fid = fopen('sp3data.txt');
tline = fgetl(fid);
while ischar(tline)
disp(tline)
tline = fgetl(fid)
end
fclose(fid);
Read about contains , strcmp, strfind etc..to check whether your desired string is present in the line...and save them .
  댓글 수: 1
gblmtc
gblmtc 2017년 11월 30일
편집: Stephen23 2017년 11월 30일
Thanks KSSV! I used the code , it works but what I need are just the lines with the word PG10. Please have a look on the file.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by