How to start reading from a specific line in a text file?

8 visualizaciones (últimos 30 días)
Bertilla Raque
Bertilla Raque el 12 de Dic. de 2019
Respondida: Cris LaPierre el 18 de Mzo. de 2020
I have a text file that has both text and numeric data. How do I read from a particular line to a particular line, say from line 40 to 50 and assign the numeric data to variable names?

Respuestas (1)

Cris LaPierre
Cris LaPierre el 18 de Mzo. de 2020
What type of text file?
Genearlly, you would use fseek to get to the starting point you want, and fgetl to read in your data line by line. However, fseek requires you to specify the number of bytes to move.
You could use textscan, which allows you to specify the number of headerlines. If the format of your numeric data is the same on each line, you could also specify how many times to apply the specified format spec (number of lines to read in).

Etiquetas

Productos


Versión

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by