MATLAB: One line form of the follwing code

one line

catchFolders = {'iptCatch','imtCatch','iftCatch','','junk','iitCatch'}; t = strfind(catchFolders(:),'Catch'); for k = length(t):-1:1 if isempty(t{k}), catchFolders(k)=[]; end end catchFolders

Best Answer

You want a one-liner? Try these:
catchFolders = {'iptCatch','imtCatch','iftCatch','','junk','iitCatch'} % data
catchFolders1 = catchFolders(~cellfun('isempty',strfind(catchFolders(:),'Catch')))
catchFolders2 = regexp(sprintf('%s ',catchFolders{:}),'\w*Catch\w*','match')
Related Question