Accept a specific type of file Matlab

1 visualización (últimos 30 días)
Lucas S
Lucas S el 15 de Abr. de 2019
Respondida: Adam el 15 de Abr. de 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

Respuestas (1)

Adam
Adam el 15 de Abr. de 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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by