How to read a specific row of data using Textscan
9 views (last 30 days)
Show older comments
Hello,
I am trying to use textscan to import a specific row of data from an ascii file. The data in the ascii file is organized as such:

I would only like to import the column headers in row 12, but only columns 2-11 (columns B-K). Below is the code I have started, but I am getting confused on how to use textscan to get the specific row of data I want. Any help would be appreciated.
fid = fopen('filelocation');
if fid == -1
disp('Error, check file location')
else
c = textscan(fid,'%s %s %s');
end
fclose(fid);
0 Comments
Accepted Answer
Ameer Hamza
on 15 Apr 2020
Edited: Ameer Hamza
on 15 Apr 2020
Try this. See the documentation of the textscan to understand these statements.
f = fopen('test.txt');
columns = textscan(f, '%s', 12, 'HeaderLines', 11);
columns = columns{1}(2:11);
fclose(f);
2 Comments
More Answers (0)
See Also
Categories
Find more on Large Files and Big Data 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!