MATLAB: How to read popup menu string and use it in another button function? MATLAB GUI

buttoncaseguipopuppopup menuswitch

I have a problem with reading a popup menu string and using it in a switch-case function in another button. My popup menu shouldn't have any function but indicating the value. But the button should know the value of popup menu and switch the case according to it. Thanks in advance.
My code:
function pushbutton1_Callback(hObject, eventdata, handles)
switch popupmenu4value
case 'A'
%function of A
case 'B'
%function of B
function popupmenu4_Callback(hObject, eventdata, handles)
contents = get(handles.popupmenu4,'String');
popupmenu4value = contents{get(handles.popupmenu4,'Value')};

Best Answer

contents = get(handles.popupmenu4,'String');
popupmenu4value = contents{get(handles.popupmenu4,'Value')};