From: Walter Roberson on
Uyen Pham wrote:

> How can I change my code so that every line in the listbox will show the
> full detail of an image, from its path to its name.

> set(handles.listbox, 'String', [path, files]);

set(handles.listbox, 'String', [repmat(path, length(files), 1),
char(files)]);
From: us on
"Uyen Pham" <uyen_bunny(a)yahoo.com> wrote in message <hs6r97$59e$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message
> > i don't think i misunderstood you...
> > the fact that the listbox control is empty does not matter at all...
> > did you try to follow the instructions(?)...
> >
> > us
>
> Sorry us! Now, I understand what you mean. However, if I insert the code
> set(handles.listbox, 'String', [path, files]);
> into the code fragment of "Select images" button, when the users choose multiple images, in the listbox, it will show the path on the first line and then the names of the images next lines (because the images are in the same folder)
>
> How can I change my code so that every line in the listbox will show the full detail of an image, from its path to its name.
>
>
> Thank you very much for your helpful and urgent support!!!

one of the solutions is outlined below

[fn,pn]=uigetfile('*.m',...
'select files','',...
'multiselect','on');
if iscell(fn)
c=cellfun(@(x) sprintf('%s%s',pn,x),fn,'uni',false);
uh=uicontrol('position',[10,10,300,500],...
'style','listbox',...
'string',c);
end

us
From: Walter Roberson on
us wrote:
> "Uyen Pham" <uyen_bunny(a)yahoo.com> wrote in message
> <hs6r97$59e$1(a)fred.mathworks.com>...
>> "us " <us(a)neurol.unizh.ch> wrote in message > i don't think i
>> misunderstood you...
>> > the fact that the listbox control is empty does not matter at all...
>> > did you try to follow the instructions(?)...
>> > > us
>>
>> Sorry us! Now, I understand what you mean. However, if I insert the code
>> set(handles.listbox, 'String', [path, files]);
>> into the code fragment of "Select images" button, when the users
>> choose multiple images, in the listbox, it will show the path on the
>> first line and then the names of the images next lines (because the
>> images are in the same folder)
>>
>> How can I change my code so that every line in the listbox will show
>> the full detail of an image, from its path to its name.
>>
>> Thank you very much for your helpful and urgent support!!!
>
> one of the solutions is outlined below
>
> [fn,pn]=uigetfile('*.m',...
> 'select files','',...
> 'multiselect','on');
> if iscell(fn)
> c=cellfun(@(x) sprintf('%s%s',pn,x),fn,'uni',false);
> uh=uicontrol('position',[10,10,300,500],...
> 'style','listbox',...
> 'string',c);
> end

Before that 'if', I would add
if ischar(fn)
fn = {fn};
end

That will cover the case that only a single file is selected, while
still gracefully doing nothing in the case where the user selects Cancel
(in which case uigetfile will return a numeric value rather than a char
or cell).
From: Uyen Pham on
Thanks for your detail instruction, us. However, I am doing the same as in your instruction, but this does not display what I want (After I click the "Select images" button and then OK, there is nothing in the listbox!)

Here is my code:
function find_Callback(hObject, eventdata, handles)
% hObject handle to find (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Read the input image

%Image formats
%.bmp .gif.hdf.jpg.jp2.jpx.pbm.pcx.pgm.png.pnm.ppm.ras.tiff.xwd

[files, path] = uigetfile(...
{'*.bmp;*.gif;*.hdf;*.jpg;*.jp2;*.jpx;*.pbm;*.pcx;*.pgm;*.png;*.pnm;*.ppm;*.ras;*.tiff;*.xwd',...
'All Image Files' },...
'Pick files','MultiSelect', 'on');
if ~path
return;
end

if ischar(files)
files ={files};
end
if iscell(files)
c=cellfun(@(x) sprintf('%s%s',pn,x),fn,'uni',false);
uh = uicontrol('position', [10,10,300,500],...
'style', 'listbox',...
'string',c);
end

Would you please helping me another time? Since I am just a newbie in Matlab. I have just started it for few weeks.

Thank you very much!!!
From: Uyen Pham on
Yeah, since I have typed some wrong words so I could not see the result. Now I am so happy to see the results. Thank you very much! I will contact you if there is something wrong. Glad to receive your urgent support!