need help building GUI that plots data
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hey everyone,
I am trying to build a GUI that allows me to open a folder, load the files into a list, and choose a file and then plot the data from that file. So far I have been able to build it to open a folder, but it will not show the particular files that I want. Any help would be appreciated.
function homework8
f=figure;
a=axes('Position',[0.1300 0.1317 0.4593 0.7731])
listbox=uicontrol('style','list','position',....
[346.3333 54.3333 135.0000 283.3334]);
btn=uicontrol('parent',f,'style','pushbutton','position',...
[344.6667 349.6667 135.6667 30.3333],'String','Select Folder','Callback',@openfolder);
%%Callbacks
function openfolder(~,~)
uigetdir
files=dir;
listbox.String={files(:).name};
end
end
0 Commenti
Risposte (3)
Walter Roberson
il 8 Apr 2018
uigetdir() does not change directories, it only returns the directory name.
folder = uigetdir();
if ~ischar(folder); return; end %user cancel
dinfo = dir(folder);
dinfo([dinfo.isdir]) = []; %throw away directories including . and ..
shortnames = {dinfo.name};
fullnames = fullfile(folder, shortnames);
You can set the ListBox to the full names, or you can set the ListBox to the short names and also save the folder information somewhere. When you go to process the file you will need the fully qualified name, either because that is what is immediately available from the list box, or by recalling the folder name and using it to qualify the short name.
0 Commenti
Vedere anche
Categorie
Scopri di più su Environment and Settings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!