How to display files with specific strings for selection in uigetfile()

4 次查看(过去 30 天)
I have a series of txt files (about 1000 files), they are named by the energy information they contains. For example, 'Singlespot 137.34 MeV,1G0T0AP,IDD,0,0.txt' and 137.34 is the energy information, and the next file is 'Singlespot 137.46 MeV,1G0T0AP,IDD,0,0.txt' and etc.
I would like to select each energy file at a time for processing.
However, if I use the following function to select one file to process at one time, for example, 137.34 to process.
uigetfile('*.txt', 'Please select the energy file you want to process');
There are 2 disadvantages: 1. it will take me a long time to scroll down (cause 1000 files are in the folder) and find the correct energy even with the energies sorted. 2. if I am not careful, I could select the wrong energy file.
How can I get MATLAB to display just specific energy file to choose? Like only display 'Singlespot 137.34 MeV,1G0T0AP,IDD,0,0.txt' as default for you to choose.
Also, there are other file types in the folder such as 'Singlespot 137.34 MeV,1G0T0AP,IDD,0,0.csv', I know that I could place these files in another different folder, but just want to know whether there is any way that I can display just the txt file for that energy.
Thank you very much for answering my question.

回答(1 个)

Jalaj Gambhir
Jalaj Gambhir 2020-4-8
Hi,
You can specify the default path and filename when you are using uigetfile. Look at an example here ("specify default file name" section). When you specify the appropriate path and file name here, the dialog box will open in the specified directory and the filename will appear in the dialog box. This will enable you to easily search the specified file.
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by