Import data of flexible / variable size with textscan
Show older comments
I have a data file with the following format (schematic):
header text 1
header text 2
header text 3
x1 x2 x3 x4 x4 x6 ... xn
1.200e-4 2.800e+3 4.512e+2 ... 8.903e+3
.
.
.
2.210e-4 2.800e+3 4.533e+2 ... 8.997e+3
In the above, the data (matrix) has an unknown number of rows and columns. I use the following command:
A = textscan(filename,formatSpec,'HeaderLines',4,'Delimiter',' ');
How to describe formatSpec in this case?
1 Comment
Rik
on 9 Feb 2017
read the file once to find out n (e.g. by counting the spaces in the 4th line), and then use repmat('%e3 ',n,1)
Answers (0)
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!