Use repmat
to create a format string based on the number of columns.
nCols = 60; format = repmat('%f', [1 nCols]); c = textscan(fid, format);
It is flexible enough to use if you have, for example, multiple row columns mixed.
nNumberCols = 58; format = ['%s%s' repmat('%f', [1 nNumberCols])]; c = textscan(fid, format);
Andrew janke
source share