MATLAB Answers

multiple default files for uigetfile

31 views (last 30 days)
Andreas Büchel
Andreas Büchel on 4 Mar 2021
Commented: Andreas Büchel on 5 Mar 2021
I selected multiple files with uigetfile. later I call uigetfile again and would like to use the previously selected files as defaults, so that I can easily deselect or add files.
Can anybody help me how to have multiple default files?
Mario Malic
Mario Malic on 4 Mar 2021
Yes, it's possible to put it in the uigetfile filter, but when you select another file (with and without Control button), list of files that were in the field are gone.

Sign in to comment.

Answers (1)

Jan on 4 Mar 2021
Edited: Jan on 4 Mar 2021
Under Windows this works:
% Select multiple M-files:
[File, Folder] = uigetfile('*.m', 'Choose files', '', 'Multiselect', 'on')
% Provide the files as char vector with double quotes aroud the names:
Default = sprintf('"%s" ', File{:});
Default(end) = []; % Remove trailing space, just to be lean
[File2, Folder2] = uigetfile('*.m', 'Choose files', Default, 'Multiselect', 'on')
% Pressing Enter selects the both default files.

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!