MATLAB: Error in getting output using pushbutton

.fis filesFuzzy Logic Toolboxmatlab gui

hi everyone..
im trying read a .fis file and evaluate it provided inputs from popupmenus,radiobuttons and textfield.i have written the following code.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

fismat=readfis('oralcancer_rulebase.fis');
out=evalfis([popupmenu2value popupmenu3value popupmenu4value num smokingvalue alcoholvalue gendervalue tumorsitevalue],fismat);
msgbox(sprintf('%d',out));
the following code is function of one of the popupmenu
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
contents1=get(handles.popupmenu2, 'String');
popupmenu2value=contents1{get(handles.popupmenu2, 'Value')};
switch popupmenu2value
case '1'
handles.value=1;
case '2'
handles.value=2;
case '3'
handles.value=3;
case '4a'
handles.value=4;
case '4b'
handles.value=5;
case 'x'
handles.value=6;
end
but im getting errors as follows
Undefined function or variable 'popupmenu2value'.
Error in testgui>pushbutton1_Callback (line 261)
out=evalfis([popupmenu2value popupmenu3value popupmenu4value num smokingvalue
alcoholvalue gendervalue tumorsitevalue],fismat);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in testgui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)testgui('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
please provide me any solution. any kind of help will be appreciated

Best Answer

srinija - the variable popupmenu2value is local to the popupmenu2_Callback function only and so is not accessible from the pushbutton1_Callback function. If you want to use that value in the pushbutton callback then you can just determine it as you are doing already in the other callback. Try
function pushbutton1_Callback(hObject, eventdata, handles)
contents1=get(handles.popupmenu2, 'String');
popupmenu2value=contents1{get(handles.popupmenu2, 'Value')};
fismat=readfis('oralcancer_rulebase.fis');
% etc.
But then you will have the same problem with all the other variables that you are trying to use that haven't been defined in your pushbutton callback
out=evalfis([popupmenu2value popupmenu3value popupmenu4value num smokingvalue alcoholvalue gendervalue tumorsitevalue],fismat);
You will need to define these variables within the pushbutton callback if you wish to make use of them (or save them to the handles structure in the other callbacks and then access them here through the struct).