How to process text file line by line

1 view (last 30 days)
Fateme Jalali
Fateme Jalali on 24 Dec 2015
Edited: dpb on 25 Dec 2015
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.

Answers (1)

dpb
dpb on 24 Dec 2015
Edited: dpb on 25 Dec 2015
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);
>>

Categories

Find more on Text Data Preparation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!