I am reading data from a table using textscan()
. The table has 90 columns and I want to read each column's values as a floating-point number. Looking at the documentation, I have to use specifier %f
- but it seems I need to use it 90 times, so I end up with this:
c = textscan(fid,'%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f
%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f
%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f
%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f');
which basically works, but I am wondering whether there is some way around to avoid typing specifier for every column I have in my table.
Use
repmat
to build your format string based on the number of columns.This is flexible enough to use if you had e.g. a couple string columns mixed in.