MATLAB: App designer: load cell array components to listbox

app designerguilistbox

Hello,
I am trying to create an UI App that creates a list of files (cell array) and displays it in a list box. This would be very helpfull so that the user can see the list of files they want to further analyse and maybe delete or add files.
I am not experienced with App designer, so I am afraid I am missing some important component in the code.
classdef SPT_GUI_v1 < matlab.apps.AppBase
%... Properties that correspond to app components ...
% Global variables
properties (Access = public)
allfiles % contains the list of selected trackmate files
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: AddButton
function AddButtonPushed(app, event)
app.allfiles = cell(0,1);
[filename,path] = uigetfile('*.*','All Files (*.*)',...
'Select files','MultiSelect','on');
filename = cellstr(filename);
path = cellstr(path);
filePattern = fullfile(path,filename);
NFiles = sum(cellfun('size',filename,1));
if NFiles > 1
filePattern = filePattern.';
end
app.allfiles = [app.allfiles;filePattern];
end
% Value changed function: TrackFilesListBox
function TrackFilesListBoxValueChanged(app, event)
app.allfiles = app.TrackFilesListBox.Value;
end
% ... Component initialization ...
end
end
Thank you for your help!!

Best Answer

I'm not sure what you are picturing as your end result, so I'll start simple. The following code will populate a list box with the files selected using uigetfile. This code would go inside your pushbutton callback function.
[filename,path] = uigetfile('*.*','All Files (*.*)',...
'Select files','MultiSelect','on');
app.filePattern = fullfile(path,filename);
app.ListBox.Items = app.filePattern;