Skipping first few lines while loading text file

조회 수: 23 (최근 30일)
alok pandey
alok pandey 2019년 10월 26일
댓글: alok pandey 2019년 10월 26일
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

채택된 답변

Guillaume
Guillaume 2019년 10월 26일
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
Guillaume
Guillaume 2019년 10월 26일
Then the easiest is problaby:
data = table2array(readtable('Full_beam-OAM_plate_l= 1_Intensity.txt'))
alok pandey
alok pandey 2019년 10월 26일
Thanks Guillaume. Cheers for your rapid response.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by