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?

1 ビュー (過去 30 日間)
gblmtc
gblmtc 2017 年 11 月 30 日
編集済み: Stephen 2017 年 11 月 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 日
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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by