file parsing identifier need to choose the correct identifier

1 回表示 (過去 30 日間)
Ihaveaquest
Ihaveaquest 2022 年 9 月 27 日
回答済み: millercommamatt 2022 年 9 月 27 日
i have this file
04_T_A_tx01_3009.txt
and my current code selects it base on identifier = 'tx'; for parsing
the correct selection would be tx01 but its selectiong both tx01 and txt
what can i do to just select tx#, theres more than just 01 and it changes
where i am using the identifier
parsed_location = strfind(parsed_data,channel_identifier);
number_location = find(~cellfun(@isempty,parsed_location)); at this point i am getting two finds i want just to find the first tx#
channel_digits = regexp(parsed_data{channel_location} , '\d', 'match');

回答 (1 件)

millercommamatt
millercommamatt 2022 年 9 月 27 日
st = '04_T_A_tx01_3009.txt';
id_cell = regexp(st,'tx\d+','match');
id_char = id_cell{1};

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by