number of rows text file

6 views (last 30 days)
fima v
fima v on 16 Feb 2017
Answered: KSSV on 16 Feb 2017
I have opened a txt file using the following code , and i see that there are 1000 lines which i can access,but length or size commands dont show the number of lines extracted(as shown in the attached photo),how can i get the number of lines.
Thanks
fid=fopen('test2.txt');
g = textscan(fid,'%s','delimiter','\n');
fclose(fid)
g{1}{4:71:10000}

Accepted Answer

KSSV
KSSV on 16 Feb 2017
Try
length(g{1})
Your g will be a cell...you can access your required line n using g{1}(n)

More Answers (0)

Categories

Find more on Environment and Settings 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!