How to textscan broken, delimited line into cell array?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have data within a text file that looks like this:
CHANNEL = ['AngR', 'Time', 'Disp', 'Velo', &
'Acce', 'Load', 'Forc', 'BLod']
These are the header lines for the subsequent data. Sadly, it is broken into 2 lines and has a pesky & at the end of the first line
Ideally i want the result to be
Headers{j,1} = AngR
Headers{j,2} = Time
Headers{j,3} = Disp
and so on. I am reading through multiple files that look like this.
Is there any way to build a format specifier that will retrieve these 2 lines at once? or do i need to fgetl them separately and then start parsing it?
댓글 수: 4
Stephen23
2019년 2월 26일
@Tyler: please upload a complete sample file, so that we can actually understand how to parse the rest of the file. Currently this satisfies your requirements and sample file:
>> str = fileread('sample.txt');
>> C = regexp(str,'(?<='')\w+(?='')','match');
>> C{:}
ans = AngR
ans = Time
ans = Disp
ans = Velo
ans = Acce
ans = Load
ans = Forc
ans = BLod
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!