Accept a specific type of file Matlab

1 回表示 (過去 30 日間)
Lucas S
Lucas S 2019 年 4 月 15 日
回答済み: Adam 2019 年 4 月 15 日
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

回答 (1 件)

Adam
Adam 2019 年 4 月 15 日
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.

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by