How can i load a List Box with filepath and filename using multiple selected file by uigetfile() ???

7 Ansichten (letzte 30 Tage)
I want to create a MATLAB GUI that contains tow object: a push button and a list box. I want to use the push button for browse multiple file. After selecting multiple file i want to load filepath and filename into list box. Here is my code:
function pushButton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile('MultiSelect','on');
set(handles.listbox1, 'String', [pathname,filename]);
It works when i select single file. It dose not work when i select multiple file. I don't know how to handle it. Please Help.....
Thanks In Advance.... :)

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 20 Jun. 2015
Try this
function pushButton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile('MultiSelect','on');
set(handles.listbox1, 'String', fullfile(pathname,filename));
  3 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 20 Jun. 2015
try this
function pushButton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile('MultiSelect','on');
f=cellfun(@(x) fullfile(pathname,x),cellstr(filename),'un',0)
set(handles.listbox1, 'String',f)
Ruhul Amin
Ruhul Amin am 20 Jun. 2015
Thank you Sir for your concern. But I am still getting Error .. :( .. ::
??? Too many inputs.
Error in ==> Training>pushButton1_Callback at 81 f=cellfun(@(x) fullfile(pathname,x),cellstr(filename),'un',0)
Error in ==> gui_mainfcn at 75 feval(varargin{:});
Error in ==> Training at 44 gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu App Building finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by