创建一个GUI,绘制抛物线y=ax^2+bx+c的图像。其中,参数a、b、c及绘图范围等通过界面上的文本编辑框输入。
布局如下,
在按钮的回调函数后写下如下代码即可。
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)
str1=get(handles.edit1,'string');
str2=get(handles.edit2,'string');
str3=get(handles.edit3,'string');
a=str2num(str1);
b=str2num(str2);
c=str2num(str3);
fh=@(x)a*x.^2+b*x+c;
handles.axes1=fplot(fh)