How to use only specific files in directory in GUI?

1 次查看(过去 30 天)
Hello all.
I have a GUI function that can open a directory/folder of images. What I would like to do is actually only select the files/images with the word "PU" in their titles. How would I be able to do this/approach this problem?
Thank you.
  2 个评论
Rik
Rik 2019-2-14
Are you using a special file picker, the builtin uigetfile, or dir to get file names?
HC
HC 2019-2-15
It is using uigetdir, yes. Within that folder/directory, I want to open only specific images with the title "PU".

请先登录,再进行评论。

回答(2 个)

Jan
Jan 2019-2-15
folder = uigetdir('Choose a folder');
List = dir(fullfile(folder, 'PU*.*'));
FileName = fullfile(folder, {List.name});
for iFile = 1:numel(FileName)
File = FileName{iFile}
... now open it
end

Robert
Robert 2019-2-15
Not sure what you mean by 'select', but you can show a user only the files containing 'PU' in their titles using
[fileName, pathName] = uigetfile('*PU*', 'This is my dialog title', 'MultiSelect', 'on');
  1 个评论
HC
HC 2019-2-15
In the GUI, I have a "Select Directory" button. This button pulls up all of the images/files in that directory/folder onto the GUI. I only want this button to choose (or "pull up" on the GUI) files with "PU" in the title.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by