Solution One
You do not need to delete the first ten rows from the file, because textscan has an option to ignore header lines, so you can use this instead:
To read 1280 columns of data you need to define this in the format string, so the final code could be something like this:
fmt = repmat('%f',1,1280);
fid = fopen('textfile.txt','rt')
out = textscan(fid, fmt, 'Delimiter',',', 'HeaderLines',10);
fclose(fid);
Solution Two
If the data in the matrix is all numeric (note the header lines do not need to be) then you could use the much simpler dlmread instead, something a bit like this: out = dlmread('textfile.txt',',',10,0);
Examples
fmt = repmat('%f',1,5);
fid = fopen('temp.txt','rt');
out_txt = textscan(fid, fmt, 'Delimiter',',', 'HeaderLines',3);
fclose(fid);
out_txt = cell2mat(out_txt)
out_dlm = dlmread('temp.txt',',',3,0)
display this in the command window:
out_txt =
0 1 2 3 4
5 6 7 8 9
out_dlm =
0 1 2 3 4
5 6 7 8 9
The sample text file that I used is attached here:
Best Answer