我找到了答案:
function test_OpeningFcn(hObject, eventdata, handles, varargin)
str = get(handles.popupmenu1,'String');
set(handles.text1,'String',str(1));
set(handles.uipanel1,'SelectionChangeFcn',@uipanel1_SelectionChangeFcn);
handles.output = hObject;
guidata(hObject, handles);
function popupmenu1_Callback(hObject, eventdata, handles)
val = get(handles.popupmenu1,'Value');
str = get(handles.popupmenu1,'String');
if val ==1
set(handles.text1,'String',str(1));
elseif val == 2
set(handles.text1,'String',str(2));
elseif val == 3
set(handles.text1,'String',str(3));
elseif val == 4
set(handles.text1,'String',str(4));
elseif val == 5
set(handles.text1,'String',str(5));
end
guidata(hObject, handles);
function uipanel1_SelectionChangeFcn(hObject, eventdata)
handles=guidata(hObject);
switch get(eventdata.NewValue,'Tag')
case 'radiobutton1'
E1str{1}='1';E1str{2}='2';E1str{3}='3';E1str{4}='4';E1str{5}='5';
set(handles.popupmenu1,'String',E1str);
case 'radiobutton2'
E2str{1}='6';E2str{2}='7';E2str{3}='8';E2str{4}='9';E2str{5}='10';
set(handles.popupmenu1,'String',E2str);
end
str = get(handles.popupmenu1,'String');
set(handles.text1,'String',str(1));