How to textscan broken, delimited line into cell array?

1 回表示 (過去 30 日間)
Tyler
Tyler 2019 年 2 月 26 日
コメント済み: Tyler 2019 年 2 月 26 日
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
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
Tyler
Tyler 2019 年 2 月 26 日
Thank you,
i have uploaded more. Basically at the bottom of the file data continues on for many many lines, but its repeatable and i have no issue retrieving it.
What i want are 2 separate header arrays -> 1 for Channel and 1 for Unit

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by