【发布时间】:2017-04-01 15:10:59
【问题描述】:
使用
x=-10:0.1:10
f=x+2
在基本的 m 文件中工作正常。
但现在我正在尝试使用 GUI 并通过输入函数来绘制绘图。 它给了我一堆错误。谁能解释当我设置了 x 的范围时如何给 y 赋值?
% --- Executes on button press in zimet.
function zimet_Callback(hObject, eventdata, handles)
% hObject handle to zimet (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=-10:0.1:10;
f=inline(get(handles.vdj,'string'))
y(x)=f
axes(handles.axes)
plot(x,y)
color=get(handles.listbox, 'value')
switch color
case 2
set(plot(x,y),'color', 'r')
case 3
set(plot(x,y),'color', 'g')
case 4
set(plot(x,y),'color', 'b')
end
style=get(handles.popupmenu, 'value')
switch style
case 2
set(plot(x,y), 'linestyle','--')
case 3
set(plot(x,y), 'linestyle','-.')
case 4
set(plot(x,y), 'linestyle',':')
end
rezgis=get(handles.grid, 'value')
switch rezgis
case 1
grid on
case 2
grid off
end
【问题讨论】: