Importing data from an ascii file.
Mostrar comentarios más antiguos
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
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
el 3 de Abr. de 2014
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.
Image Analyst
el 3 de Abr. de 2014
Use the new readtable function:
t = readtable(fullFileName, 'HeaderLines', 1); % Skip 1 line in the file.
1 comentario
Joseph Cheng
el 3 de Abr. de 2014
ooo... when did that come out?
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!