I have to creade a function that takes two inputs: a cell array of strings (let's call it txt) and a single string (let's call it str). The function has to remove each element of the cell vector txt whose string is either identical to str or contains str as a substring.
For the moment I've tried with the following:
function c = censor( txt,str )
c = txt;
n = length(c);
for i = 1:n
a = c{ i };
a( a == str ) = [];
c{i} = a;
end
end
But it doesn't work, it gives the error that Matrix dimensions must agree. I understand that it might be because str has more than one character, but I don't know how to find if str is contained in any of the strings of the cell array txt.