function fileList = getFilteredFileList(directory,filterpattern,fullpath) if nargin < 3 fullpath = 1; end files = dir(directory); fileList = []; for f = 1:numel(files) if files(f).isdir continue end if regexp(files(f).name,filterpattern,'once') if fullpath fileList = strvcat(fileList, fullfile(directory,files(f).name)); else fileList = strvcat(fileList, files(f).name); end end end end