hello dears . i must read a text file such this :
person01_boxing_d1 frames 1-95, 96-185, 186-245, 246-360
person01_boxing_d2 frames 1-106, 107-195, 196-265, 305-390
person01_boxing_d3 frames 1-95, 96-230, 231-360, 361-465
person01_boxing_d4 frames 1-106, 107-170, 171-245, 246-370
person01_handclapping_d1 frames 1-102, 103-182, 183-260, 261-378
person01_handclapping_d2 frames 1-162, 163-282, 358-472, 473-550
person01_handclapping_d3 frames 1-125, 126-225, 226-330, 331-428
person01_handclapping_d4 frames 1-110, 111-216, 217-292, 293-390
------------------------------------- i need this information
person 01 _ boxing _d 1 frames 1 - 95 , 96 - 185 , 186 - 245 , 246 - 360
i.e :
01 boxing 1 1 95 96 185 186 245 246 360
i can not read all information because action types (e.g boxing , handclapping , ..) have different length . please help me . thank you for your time .

 採用された回答

dpb
dpb 2014 年 10 月 1 日

0 投票

>> s='person01_boxing_d1 frames 1-95, 96-185, 186-245, 246-360';
>> fmt=['person%2d%sd%d frames ' repmat('%d-%d',1,4)];
>> a=textscan(s,fmt,'collectoutput',1,'delimiter','_,')
a =
[1] {1x1 cell} [1x9 int32]
>> a{:}
ans =
1
ans =
'boxing'
ans =
1 1 95 96 185 186 245 246 360
>> s='person01_handclapping_d2 frames 1-162, 163-282, 358-472, 473-550';
>> b=textscan(s,fmt,'collectoutput',1,'delimiter','_,')
b =
[1] {1x1 cell} [1x9 int32]
>> b{:}
ans =
1
ans =
'handclapping'
ans =
2 1 162 163 282 358 472 473 550
>>

1 件のコメント

majid
majid 2014 年 10 月 1 日
編集済み: majid 2014 年 10 月 1 日
i don't know what to say . thats perfect . you're too kind . thanks again.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Data Preparation についてさらに検索

質問済み:

2014 年 10 月 1 日

編集済み:

2014 年 10 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by