UIGETFILE to filter out files starting with a specific character
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
dpb
el 26 de Jul. de 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>
Respuestas (1)
Pramil
el 29 de Jul. de 2025
Editada: Pramil
el 29 de Jul. de 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 comentarios
dpb
el 31 de Jul. de 2025
Editada: dpb
el 31 de Jul. de 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.
Ver también
Categorías
Más información sobre Programming Utilities en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!