What needs to be done is to encapsulate this idea as a function. Or built-in:
substrmatch = @(x,y) ~cellfun(@isempty,strfind(y,x))
findmatching = @(x,y) y(substrmatch(x,y))
Or contained in two m files:
function idx = substrmatch(word,cellarray)
idx = ~cellfun(@isempty,strfind(word,cellarray))
and
function newcell = findmatching(word,oldcell)
newcell = oldcell(substrmatch(word,oldcell))
So now you can just type
>> findmatching('words',cellArray)
ans =
'nicewords' 'morewords'
source
share