For this case, you can do the following:
fid = fopen('indices.txt');num_ints = 7;num_rows = 4;format = [repmat('%d ', 1, num_ints), '%s'];weights = textscan(fid, format, num_rows);weights = [weights{1:num_ints}];fclose(fid);
The downside of course is that you have to know the number of rows that you're reading beforehand. You could try calling textscan in a loop, but that doesn't seem to be how it's meant to be used (and I would rather use fgetl instead if I'm trying to read the file line-by-line).