Hi I have a problem in MATLAB pop up menu in GUI...The code looks as follows :
function popupmenu1_Callback(hObject, eventdata, handles,varargin)
% Set current data to the selected data set.
ind = get(handles.popupmenu1,'value') ;
case 1 % User selects displacement field set(handles.popupmenu1,'string','displacement') case 2 % User selects stress field set(handles.popupmenu1,'string','stress') end
When I run the above, the pop menu always selects only case 1...it never selects case 2. If I don't set the handles value to 1, when I select case 2 , the following errors comes on the screen and popup menu disappears....
Warning: popupmenu control requires that Value be an integer within String range Control will not be rendered until all of its parameter values are valid
I tried a lot..but of no use then waste of time...browsed in other tags of math works but they were not helpful....
What is the solution for this??
Thanks in advance
No products are associated with this question.
% Set current data to the selected data set. set(handles.popupmenu1,'value',1) ;
and it should work just fine, that code was setting the value to 1 everytime the user changed the popupmenu value
When you execute
you change the popupmenu to have only a single string in its list -- but your Value (the index in to the list of strings) is still set to 2, which is more than the number of strings you have.
I do not know why you are trying to change the entire contents of the popup menu when the user selects an entry in it ?