我想在另一个字符串的单元数组中使用
strfind
函数,通过cellfun
函数查找每个字符串的索引,并将它们从该单元数组中排除。strings = {'aaa','bbb','ccc','ddd','eee','fff','ggg','hhh','iii','jjj'};
excludedStrings = {'b','g','h'};
idx = cellfun('strfind',strings,excludedStrings);
idx = cell2mat = idx;
idx = reshap(idx,numel(idx),1);
idx = unique(idx);
strings(cell2mat(idx)) = [];
在cellfun
调用行中有错误,我该如何修复?
cellfun(@(x) strfind(strings,x), excludedStrings, 'UniformOutput', 0)
是否接近于您想要实现的目标? - Tim