MATLAB: Is it possible to let MATLAB choose a file in a path if the user enters the first letters belonging to the file

app designerfile selectmatlab gui

Hi all,
I am designing a user interface using Appdesigner. This UI needs to select a folder and add this to the path. After having done this, the user can enter the first letters of the file (for example: ID) and then enter the number of the file (for example 001, 010, 011….etc). How can I let MATLAB search the folder(path) for this specific file?
Any help would be appreciated!

Best Answer

I agree with the other two experts (Stephen and Guillaume).
Use dir() instead of dos() or you can use datastore().
And use fullfile() to create full file names rather than using cd(). See the FAQ: http://matlab.wikia.com/wiki/FAQ#Where_did_my_file_go.3F_The_risks_of_using_the_cd_function.
Get the string from the edit field (sorry I only know how to do it in GUIDE so far, not App Designer), then create the list of filenames.
filePattern = sprintf('%s*.*', prefix);
fileInfo = dir(filePattern);