MATLAB: How to read a specific row of data using Textscan

fopenrowtextscan

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);

Best Answer

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);