Hi Brian,
To plot data from the file selected in the list box, the name of the file needs to be extracted from the cell array in listbox.String. This can be done by using the listbox.Value property to index into the cell array.
Here’s some code to help:
f=figure;
x=linspace(0,6,10020);
a=axes('Position',[0.1300 0.1317 0.4593 0.7731]);
listbox=uicontrol('style','list','position',....
[346.3333 54.3333 135.0000 283.3334]);
listbox.Callback = {@Plot, listbox, a};
btn=uicontrol('parent',f,'style','pushbutton','position',...
[344.6667 349.6667 135.6667 30.3333],...
'String','Select Folder','Callback',{@openfolder,listbox});
%%Callbacks
function openfolder(~,~, lb)
folder = uigetdir();% returns the path for the directory
files = dir(folder); % sets the directory to chosen folder
lb.String ={files(:).name}; % puts files into listbox
end
function Plot(~,~,lb,ax)
fileName = lb.String{lb.Value}; %Getting file name from listbox.String
data = table2array(readtable(fileName)); %take data from file
plot(ax,data(:,1),data(:,2));
end