Importing data from an ascii file.

I want to import data into a matrix in matlab. The issue arises because I have a bunch of junk that I don't want before my data. How can I import my data into matlab output it in a matrix in a certain file name. My data looks like this
JUNK JUNK JUNK JUNK JUNK JUNK JUNK JUNK JUNK JUNK JUNK
#' Start of Data:
Data I want
The "# Start of Data:" is actually there I want everything after that line. Any assistance you can give would be very appreciated.

Respuestas (2)

Joseph Cheng
Joseph Cheng el 3 de Abr. de 2014

0 votos

you can use dlmread() which you can specify the specific row and column to start importing the data. One thing to remember dlmread starts counting with 0 not 1 like the rest of matlab. so the first column and row is both 0.

2 comentarios

Matthew
Matthew el 3 de Abr. de 2014
So if my data was on the 200th line and was separated with spaces I'd use
dlmread('filename.asc', ' ', 200, 0)
Is that correct? I don't have that much experience with coding.
Joseph Cheng
Joseph Cheng el 3 de Abr. de 2014
I'd test it out? but i think it may be 199 line but easiest way to check is to either try it or open the txt file in a text editor that displays line numbers and see whether the junk is from 0 to 199 or 1 to 200. Both would have 200 lines but dlmread counts the first row as 0.

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 3 de Abr. de 2014
Use the new readtable function:
t = readtable(fullFileName, 'HeaderLines', 1); % Skip 1 line in the file.

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 3 de Abr. de 2014

Comentada:

el 3 de Abr. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by