How to process text file line by line

1 回表示 (過去 30 日間)
Fateme Jalali
Fateme Jalali 2015 年 12 月 24 日
編集済み: dpb 2015 年 12 月 25 日
Hi,I have a text file dataset.my data in the text file is like this:
220 210
1678
380 568 90
i want to process each line of data separately.i need the code to read each line.

回答 (1 件)

dpb
dpb 2015 年 12 月 24 日
編集済み: dpb 2015 年 12 月 25 日
doc fgetl
>> fid=fopen('fatem.dat');
>> while ~feof(fid)
x=sscanf(fgetl(fid),'%f');
% insert desired processing here; just display the data here for example
disp(x.')
end
220 210
1678
380 568 90
>> fid=fclose(fid);
>>

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by