Reputation: 17
I have a file that is nth lines long and I want to extract line 10 from the file and read it in as a string. I don't want to import the file, I don't want to search for a string in the file, and I don't want to skip nth lines, I just want to read in line 10. I'm having trouble scripting this up, how can I do this?
fileID = fopen(test.txt','r');
fclose(fileID)
Upvotes: 0
Views: 731
Reputation: 16
Matlab can't find the nth line without linearly searching for eol characters. Even if a function did exist to go to line 10, that function would still need to read every line and check for eol. You have to either skip n lines use fgets/fgetl or use fseek if you know how many bytes precede the line.
Upvotes: 0