一、功能描述:能够将选定的字符展示在edit button控件中
二、步骤:
2.1、需要ListBox、pushbutton和edit Text控件。同样,ListBox控件中value的值对应string中的值,1对应t,2 对应sin(t)。
2.2、代码如下
% --- Executes on button press in pushbutton1.
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)
var1=get(handles.listbox1,'value'); %得到value值,value值对应不同的字符
str=get(handles.listbox1,'string'); %cell类型,得到listbox1中string属性中的所有字符
set(handles.edit1,'string',str{var1});
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
var2=get(handles.listbox1,'value');
str=get(handles.listbox1,'string');
set(handles.edit2,'string',str{var2});