How to find the corresponding position in a string

5 次查看(过去 30 天)
How to find the corresponding string in a string set test_str = ['a';'b';'c'] test_str = 'a' 'b' 'c' How can i find out c and the output string is at position 3 of c

回答(2 个)

Matt J
Matt J 2022-8-30
编辑:Matt J 2022-8-30
test_str={'a','b','c'};
[exists,location]=ismember('c',test_str)
exists = logical
1
location = 3

Matt J
Matt J 2022-8-30
编辑:Matt J 2022-8-30
test_str=['a','b','c']
test_str = 'abc'
location = strfind(test_str,'c')
location = 3

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by