Importing files in folder into listbox and opening one at a time
6 views (last 30 days)
Show older comments
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 :)
0 Comments
Answers (1)
Payas Bahade
on 9 Apr 2020
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!
0 Comments
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!