Accept a specific type of file Matlab

3 views (last 30 days)
Lucas S
Lucas S on 15 Apr 2019
Answered: Adam on 15 Apr 2019
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

Answers (1)

Adam
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.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!