0

我有这些功能和一个带有两个轴(axes3 和axes4)和两个编辑文本和一个按钮的GUI。

function z=add(x,y)
z=x+y;
end

function z=mul(x,y)
z=x*y;
end

function pre(z1,z2)
plot(handles.axes3,z1,'b*');
set(get(handles.axes3,'Title'),'String','Number of Iterations');
set(get(handles.axes3,'XLabel'),'String','Number of Comlpeted Tours');
set(get(handles.axes3,'YLabel'),'String','MIN of Lenght of Tours');

plot(handles.axes4,z2,'r*');
set(get(handles.axes4,'Title'),'String','Number of Iterations');
set(get(handles.axes4,'XLabel'),'String','Number of Comlpeted Tours');
set(get(handles.axes4,'YLabel'),'String','MIN of Lenght of Tours');
end

function main(x,y)
z1=add(x,y);
z2=mul(x,y);
pre(z1,z2);
end

function pushbutton1_Callback(hObject, eventdata, handles)
x=str2double(get(handles.edit1_x,'String'));
y=str2double(get(handles.edit2_y,'String'));
main(x,y);

我有这个错误:

??? Undefined variable "handles" or class "handles.axes3".
Error in ==> main at 6
        plot(handles.axes3,z1,'b*');

如何通过从 pre(z1,z2) 调用在 GUI 中的轴中显示我们的输出?

4

1 回答 1

0

如果您不给它句柄, pre() 如何访问句柄?我认为这可能会解决它。

function z=add(x,y)
z=x+y;
end

function z=mul(x,y)
z=x*y;
end

function pre(z1,z2,handles)
plot(handles.axes3,z1,'b*');
set(get(handles.axes3,'Title'),'String','Number of Iterations');
set(get(handles.axes3,'XLabel'),'String','Number of Comlpeted Tours');
set(get(handles.axes3,'YLabel'),'String','MIN of Lenght of Tours');

plot(handles.axes4,z2,'r*');
set(get(handles.axes4,'Title'),'String','Number of Iterations');
set(get(handles.axes4,'XLabel'),'String','Number of Comlpeted Tours');
set(get(handles.axes4,'YLabel'),'String','MIN of Lenght of Tours');
end

function main(x,y,hanldes)
z1=add(x,y);
z2=mul(x,y);
pre(z1,z2,handles);
end

function pushbutton1_Callback(hObject, eventdata, handles)
x=str2double(get(handles.edit1_x,'String'));
y=str2double(get(handles.edit2_y,'String'));
main(x,y,handles);
于 2013-07-04T10:30:04.543 回答