Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
Ali
Posts:
18
Registered:
12/11/10
|
|
reading the previous line in a text file
Posted:
Dec 12, 2010 7:37 AM
|
|
use txtscan instead of fgetl like this:
fid = fopen(InputFile); txtData = textscan(fid,'%[^\n\r]'); txtData = txtData{:}; fclose(fid);
this saves the whole file in a cell array... each line in a cell of the array.. you can choose the line you want by using its index. ALi
"Peli " <bogus88@gmail.com> wrote in message <ie2epd$r06$1@fred.mathworks.com>... > I need to read a large text file and use only certain lines. > I can decide wether I need a line only by using information in the next line. > > line > line > will need this line data 1323 34 23 53425 > use the previous line > line > line > > I read the text using "fopen" and "fgetl". > how can I read the previous line in the text (in relation to the file fid)? > > file_fid=fopen('textfile.txt', 'r'); > tline=fgetl(file_fid);
|
|
|
|