Note this complex code:
if isempty(Prefix) == 1; Prefixval = 0; else Prefixval = 1; end switch Prefixval case 1 set(handles.findspecfiles,'Enable','On'); case 0 set(handles.findspecfiles,'Enable','Off'); end
could be simplified to just half the code:
if isempty(Prefix) set(handles.findspecfiles,'Enable','Off'); else set(handles.findspecfiles,'Enable','On'); end
Why make it more complex than it needs to be? Also note that testing isempty(...)==1 serves no purpose whatsoever: why test a logical value against 1 just to produce another exactly identical logical value? Some beginners like to do this, for reasons that have never been made clear to me.
I would also suggest that your Pattern should include the file extension: [Prefix,'*.csv'], just to make it a tiny bit more robust. Perhaps even [Prefix,'*sec.csv'], then dir already finds only the filenames that match that format, and so you do not need to use that code to filter a larger list of filenames.