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.

Réponses (2)

Joseph Cheng
Joseph Cheng le 3 Avr 2014

0 votes

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 commentaires

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 le 3 Avr 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.

Connectez-vous pour commenter.

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

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Question posée :

le 3 Avr 2014

Commenté :

le 3 Avr 2014

Community Treasure Hunt

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

Start Hunting!

Translated by