a={'hello','world','friends'};
我想看看单元格数组中的每个单词是否包含字母'o',如何使用 cellfun()
在紧凑的表达式中实现以下内容?
b = [ contains(a(1),'o') contains(a(2),'o') contains(a(3),'o')]
您不需要cellfun
,如果您阅读了文档,则contains
在字符阵列中本地工作:
a = {'hello', 'world', 'friends'};
b = contains(a, 'o');
返回:
b =
1×3 logical array
1 1 0