UIGETFILE start in another directory AND choose two default file types

조회 수: 17 (최근 30일)
Adriano
Adriano 2011년 8월 18일
댓글: PL.R 2021년 1월 21일
I am using UIGETFILE to choose Excel files, with .xls AND .xlsx extension. Also, I want UIGETFILE to start in another directory. I already looked at the documentation and in this post. I know I would have to use something like this:
uigetfile([pwd '\folder1\*.xls'], 'Select file');
However, that would only allow me to select .xls files. I want it to allow me to select .xls files AND .xlsx files.
How can I do this?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 8월 18일
uigetfile(fullfile(pwd,'folder1','*.xls;*.xlsx'),'select file')
  댓글 수: 2
Adriano
Adriano 2011년 8월 18일
Thanks, it worked. This option should be explicitly stated in the documentation.
Fangjun Jiang
Fangjun Jiang 2011년 8월 18일
I agree! It took me a while to figure it out.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

William Frane
William Frane 2012년 1월 20일
There's a slightly more flexible way to accomplish this:
uigetfile({'*.txt;*.doc' 'Text file or Word document';'*.txt' 'Text file'; '*.doc' 'Word document'},'Select a file','C:\');
This makes use of uigetfile's optional DefaultName argument to specify the starting path. Since FilterSpec isn't being used to provide the path, it can be a cell array of strings, which enables the use of custom file type descriptions (something that's not possible if FilterSpec is a single string as in the example above).
  댓글 수: 1
PL.R
PL.R 2021년 1월 21일
I was looking for this for a while. Tank you so much. Should be the accepted answer

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by