【发布时间】:2016-09-14 13:56:00
【问题描述】:
我一直在尝试从外部函数获取图形到 GUI 内的轴。我不使用 GUIDE。我尝试了多种方法,但我一直收到错误
Not enough input arguments.
Error in dummyGUI/plotButton_callback (line 19)
set(hfigure,'CurrentAxes',handles.axes1)
现在我已经制作了一个虚拟 GUI,并且在命令窗口中制作了绘图,但我无法摆脱错误。
我的代码很简单,如下: 函数dummyGUI
f = figure('Name','Name1','Tag','Name1','Units','Pixels','Position',[50 50 1000 600]);
plotButton = uicontrol('Style', 'pushbutton',...
'Parent', f,...
'String', 'plot',...
'Units', 'pixels', 'Position', [100 400 100 20],...
'Callback',@plotButton_callback);
axes1 = axes('Parent', f,...
'Units', 'pixels', 'Position', [50 50 500 300]);
function plotButton_callback(hObject, eventdata, handles)
hfigure = getappdata(0,'hfigure');
axes1 = getappdata(0,'axes1')
set(hfigure,'CurrentAxes',handles.axes1)
end
end
我在命令窗口中使用的代码是:
x = 1:100;
plot(x,x.^2);
hfigure = gcf;
hfigure = setappdata('0','hfigure')
显然缺少一些东西,但我不知道是什么。
非常感谢。
罗马音
【问题讨论】:
标签: matlab user-interface matlab-figure axes