From: aashay vanarase on

> If you want to find out which file was selected, then get() the Value of the
> uicontrol, and get() the String property of the uicontrol, and index the
> String property by the value.
>
i cant seem to get the 'string' that is currently selected from the whole dropdown list... i want the selected string, not the whole list of all options of the string value
From: Husam Aldahiyat on
"aashay vanarase" <aashayv(a)gmail.com> wrote in message <hnv3t7$m4j$1(a)fred.mathworks.com>...
>
> > If you want to find out which file was selected, then get() the Value of the
> > uicontrol, and get() the String property of the uicontrol, and index the
> > String property by the value.
> >
> i cant seem to get the 'string' that is currently selected from the whole dropdown list... i want the selected string, not the whole list of all options of the string value

use

a = get(handle,'string') % whole strings
b = get(handles,'value') % index of selected string

c = a{b}; % selected string
From: aashay vanarase on
H1 = findobj(gcf,'Tag','popupmenu');
a = get(H1,'string') % whole strings
b = get(H1,'value') % index of selected string
c = a{b}; % selected string

where should i put this prog so that value is updated every time user selects diff item in drop down list.. i am facing this prob as my popup list is generated in the callback of a push button...

here's my prog...

function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)

location=uigetdir;
imagefiles=dir(location);
imagenames= {'select faulty image'};
for index = 1:length(imagefiles)
singlefile= imagefiles(index).name;
[folder, name, extension, version] = fileparts(singlefile);
extension = lower(extension);
switch (extension)
case {'.jpg'}
imagenames = [imagenames; singlefile];
otherwise
end
end
h = uicontrol('Style','popupmenu', 'String', imagenames,'Position',[100 200 200 10],'callback','dispimg');
imagenames = get(h,'String')
iv=get(h,'value')

callback 'dispimg' is:

H1 = findobj(gcf,'Tag','popupmenu');
a = get(H1,'string') % whole strings
b = get(H1,'value') % index of selected string
c = a{b}; % selected string

here iv always displays '1' as it is set before user has a chance to select, but when i try to get value in the call back, i get empty sets...

when i change selected object it returns
a =

[]


val =

[]
From: aashay vanarase on
H1 = findobj(gcf,'Tag','popupmenu');
a = get(H1,'string') % whole strings
b = get(H1,'value') % index of selected string
c = a{b}; % selected string

where should i put this prog so that value is updated every time user selects diff item in drop down list.. i am facing this prob as my popup list is generated in the callback of a push button...

here's my prog...

function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)

location=uigetdir;
imagefiles=dir(location);
imagenames= {'select faulty image'};
for index = 1:length(imagefiles)
singlefile= imagefiles(index).name;
[folder, name, extension, version] = fileparts(singlefile);
extension = lower(extension);
switch (extension)
case {'.jpg'}
imagenames = [imagenames; singlefile];
otherwise
end
end
h = uicontrol('Style','popupmenu', 'String', imagenames,'Position',[100 200 200 10],'callback','dispimg');
imagenames = get(h,'String')
iv=get(h,'value')

callback 'dispimg' is:

H1 = findobj(gcf,'Tag','popupmenu');
a = get(H1,'string') % whole strings
b = get(H1,'value') % index of selected string
c = a{b}; % selected string

here iv always displays '1' as it is set before user has a chance to select, but when i try to get value in the call back, i get empty sets...

when i change selected object it returns
a =

[]


val =

[]
 | 
Pages: 1
Prev: signal processing
Next: reshape