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

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.... :)

 Respuesta aceptada

Try this
function pushButton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile('MultiSelect','on');
set(handles.listbox1, 'String', fullfile(pathname,filename));

3 comentarios

Now It's giving this ERROR :
??? Function 'eq' is not defined for values of class 'cell'.
Error in ==> eq at 18 [varargout{1:nargout}] = builtin('eq', varargin{:});
Error in ==> fullfile at 40 if (f(end)==fs) & (part(1)==fs),
Error in ==> Training>pushButton1_Callback at 81 set(handles.listBox1, 'String', fullfile(pathname,filename));
Error in ==> gui_mainfcn at 75 feval(varargin{:});
Error in ==> Training at 44 gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback.
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)
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Preguntada:

el 20 de Jun. de 2015

Comentada:

el 20 de Jun. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by