Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 使用Matlab查找字符串中包含的子字符串_String_Matlab_Find - Fatal编程技术网

String 使用Matlab查找字符串中包含的子字符串

String 使用Matlab查找字符串中包含的子字符串,string,matlab,find,String,Matlab,Find,我有一个名为“condition”的char变量。此变量的内容类似于: “21331-54-task-5da1-6256853-35-1-3.mp4” 我需要确定名称中包含以下哪个字符:25、35、45。 我尝试使用contains(),但这只能告诉我其中一个是否包含在条件中。它没有告诉我哪一个被包含 我还尝试: strofind={'25','35','45'} pos=strfind(strofind,条件) 但它给了我以下结果: 位置= 1×3单元阵列 {0×0 double} {0

我有一个名为“condition”的char变量。此变量的内容类似于: “21331-54-task-5da1-6256853-35-1-3.mp4”

我需要确定名称中包含以下哪个字符:25、35、45。 我尝试使用contains(),但这只能告诉我其中一个是否包含在条件中。它没有告诉我哪一个被包含

我还尝试:

strofind={'25','35','45'}

pos=strfind(strofind,条件)

但它给了我以下结果:

位置=

1×3单元阵列

{0×0 double}    {0×0 double}    {0×0 double}
有没有关于如何解决这个问题的建议? 先谢谢你

~cellfun(@isempty, regexp(condition, strToFind, 'once'))
将给出一个与
strofind
大小相同的逻辑数组,告知
strofind
中的每个字符串是否在
条件下存在

你也可以使用

cellfun(@(x) contains(condition, x), strToFind)
将给出一个与
strofind
大小相同的逻辑数组,告知
strofind
中的每个字符串是否在
条件下存在

你也可以使用

cellfun(@(x) contains(condition, x), strToFind)