Skipping first few lines while loading text file
42 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
alok pandey
il 26 Ott 2019
Commentato: alok pandey
il 26 Ott 2019
I have a text file which looks like the one attached. How to skip first five lines and import the rest as a matrix. Thanks in advance for help
0 Commenti
Risposta accettata
Guillaume
il 26 Ott 2019
That file is a mess. It looks like the number of spaces around the numbers is significant, which is never a good idea.
Thankfully for you readmatrix seem to import the file correctly. It also detects the number of header lines on its own. All the importing functions (csvread, dlmread, readtable, readmatrix) allows you to specify the number of header lines if you need to. The last two can detect that automatically, so:
data = readmatrix('Full_beam-OAM_plate_l= 1_Intensity.txt')
5 Commenti
Guillaume
il 26 Ott 2019
Then the easiest is problaby:
data = table2array(readtable('Full_beam-OAM_plate_l= 1_Intensity.txt'))
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Text Files in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!