UIGETFILE to filter out files starting with a specific character
20 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to filter out file starting with a specific character. This code works on Matlab 2024b and older versions:
uigetfile('_*.dat')
…but in MATLAB R2025a, it gives a warning:
Warning: Invalid file filter _*.dat
And the fillter does not work.
How to apply this filter in Matlab 2025?
3 commentaires
dpb
le 26 Juil 2025
I did just reconfirm works as expected with earlier release on Win10, R2021b.
Submit this to Mathworks as an official support request/bug at <Product Support Page>
Réponses (1)
Pramil
le 29 Juil 2025
Modifié(e) : Pramil
le 29 Juil 2025
Hi QUANG,
I faced a similar issue in MATLAB R2025a and it appears to be a bug. The workaround for this if you want to continue using R2025a seems to be just typing in the file name or selecting the same from the available options once the modal for file selection opens.
>> [file, path] = uigetfile('_*.txt')
Warning: Invalid file filter _*.txt
file =
'_random.txt'
path =
'C:\Users\pkesarwa\Downloads\New folder\'
Hope this helps!
2 commentaires
dpb
le 31 Juil 2025
Modifié(e) : dpb
le 31 Juil 2025
"my goal is to filter only files in the '_*.dat' format..."
I think the only programmatic workaround(*) until Mathworks issues an update or patch that addresses the specific issue (and I wouldn't be holding my breath waiting) is as suggested above to use a directory search output filtered by the wildcard pattern and then present those results to the user for selection.
(*) There is an alternate which would be to rename the files to replace the underscore with some other unique allowable character and then filter on that pattern. This is, of course, recognizably not an ideal solution to have to rename the files back to their original or just concede and use a different naming scheme; ergo, not a desireable option.
For Windows, the following would be allowable
Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:
- The following reserved characters:
- < (less than)
- > (greater than)
- : (colon)
- " (double quote)
- / (forward slash)
- \ (backslash)
- | (vertical bar or pipe)
- ? (question mark)
- * (asterisk)
- Integer value zero, sometimes referred to as the ASCII NUL character.
- Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.
Voir également
Catégories
En savoir plus sur Programming Utilities dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!