Importing files in folder into listbox and opening one at a time

7 次查看(过去 30 天)
Hi,
I would like to be able to load a folder which contains multiple files into a listbox in the app designer. The files in this listbox should then be able to be opened and read by the GUI.
The GUI I've designed has the reading cabaility if I open each file manually but I would like to be able to populate a listbox with all the files first, and then read adn access ach one individually.
Any help would be greatly appreciated!
Thanks :)

回答(1 个)

Payas Bahade
Payas Bahade 2020-4-9
Hi George,
I have written a code to import multiple files from folder into listbox. I have added startupFnc to import files into the listbox. You will need to add this function in your file reading capability code. For illustraton purpose, I have used ListBoxValueChanged callback to read data from files.
% Code that executes after component creation
function startupFcn(app)
fileExtPattern = fullfile('EnterYourPathHere'); %Enter path eg. 'C:\Users\XYZ\Desktop\myFolder'
dirInfo = dir(fileExtPattern);
app.FIlenamesListBox.Items ={dirInfo.name};
end
Please refer documentation of fullfile and dir for more details. I have also attached the .mlapp file for reference.
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by