Accept a specific type of file Matlab
3 views (last 30 days)
Show older comments
I have a GUI using a Browe Button to search a file :
function Browse(app, event)
FileName,FilePath ]= uigetfile();
ExPath = fullfile(FilePath, FileName);
app.FileTextArea.Value = ExPath;
end
And i save the file Path in a Text Area. I have another button that start a matlab script with the file path as parameter and so i would like to accept only a certain type of file (.ctm which is my own type of file) if possible like this :
if file is .ctm
do something
else
print('a .ctm file is needed')
Thanks for helping
0 Comments
Answers (1)
Adam
on 15 Apr 2019
doc uigetfile
gives examples of specifying filters for file type.
You can use a generic uigetfile and a check like that after if you prefer, but it seems to make more sense to just use the uigetfile filter, e.g.
[file, path] = uigetfile( '*.ctm', 'Some title or other' )
though there are fancier options too.
0 Comments
See Also
Categories
Find more on Environment and Settings 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!