faster way to read formatted ascii

5 visualizaciones (últimos 30 días)
sergio cogliati
sergio cogliati el 25 de Mzo. de 2015
Respondida: Titus Edelhofer el 25 de Mzo. de 2015
I have to read a large number of formatted text ascii files which are composed by 260 lines by 3662 columns by exploiting i/o level fgetl/fscanf. The 1th lines is the header, successive lines contain data. The columns 1:14 are time of measurements and other instrument specifications, while columns [15:3662,259] can be uploaded as a matrix.
I tryed by using fgetl() + strsplit(), but it seems to me that the output from strsplit is a cell array and it takes a lot of time to convert the huge numerical matrix into a double array.
What is the most efficient (in terms of time of reading) way to read these files?
thank you in advance
  2 comentarios
Star Strider
Star Strider el 25 de Mzo. de 2015
Experiment with the textscan function. It may do what you want.
Stephen23
Stephen23 el 25 de Mzo. de 2015
Editada: Stephen23 el 25 de Mzo. de 2015
Use textscan instead: any possible small time saving is going to be many times smaller than the time you will spend trying to get an fgetl solution working properly.

Iniciar sesión para comentar.

Respuestas (1)

Titus Edelhofer
Titus Edelhofer el 25 de Mzo. de 2015
Hi,
as an alternative to textscan, you can continue using the importer as you do but instead of hitting the import data click on the triangle to get to the menu below that offers "Generate function". This should do most of the work for you and you can use the generated function to read your files in a loop ...
Titus

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by