Import data of flexible / variable size with textscan
Afficher commentaires plus anciens
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 commentaire
Rik
le 9 Fév 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)
Réponses (0)
Catégories
En savoir plus sur Large Files and Big Data dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!