give labels according to string
古いコメントを表示
I have a cell array of strings with the following pattern
String Label
'Abc\a1\L\XYZ1R08' 1
'Abc\a1\R\XYZ1R09' 1
'Abc\a1\R\XYZ1R10' 1
'Abc\b2\L\XYZ2L01' 2
'Abc\b2\R\XYZ2L02' 2
'Abc\b2\R\XYZ2L03' 2
'Abc\c3\L\XYZ2L04' 3
'Abc\c3\R\XYZ2L05' 3
'Abc\d4\L\XYZ2L06' 4
'Abc\d4\R\XYZ2L07' 4
i wanted to give a new variable, "Label', values according to a1,b2,c3,d4, etc
3 件のコメント
Philippe Lebel
2019 年 11 月 20 日
I'm not sure i understood what you wanted but here's my try:
elements = strsplit(my_string,'\');
if strcmp(elements(2),'a1')
Label = 1337;
end
Rik
2019 年 11 月 20 日
Is that label guaranteed to be between the first two slashes?
Elysi Cochin
2019 年 11 月 20 日
編集済み: Elysi Cochin
2019 年 11 月 20 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!