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

 Accepted Answer

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

3 Comments

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.

Sign in to comment.

More Answers (0)

Categories

Find more on App Building in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!