How to display files with specific strings for selection in uigetfile()
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
congcong am 4 Mär. 2020
Beantwortet: Jalaj Gambhir am 8 Apr. 2020
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.
Jalaj Gambhir am 8 Apr. 2020
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!
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!