matlab中GUI的问题
全部语句如下(带%的注释都删了functionvarargout=lianxi2delet(varargin)gui_Singleton=1;gui_State=stru...
全部语句如下(带%的注释都删了
function varargout = lianxi2delet(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @lianxi2delet_OpeningFcn, ...
'gui_OutputFcn', @lianxi2delet_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function lianxi2delet_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = lianxi2delet_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
a=num2double(get(handles.edit1,'string'));
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
b=num2double(get(handles.edit2,'string'));
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function pushbutton1_Callback(hObject, eventdata, handles)
plot(a,b,'r*')
两个文本框中输入坐标,按钮后画出图,请问哪里有错? 展开
function varargout = lianxi2delet(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @lianxi2delet_OpeningFcn, ...
'gui_OutputFcn', @lianxi2delet_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function lianxi2delet_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = lianxi2delet_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
a=num2double(get(handles.edit1,'string'));
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
b=num2double(get(handles.edit2,'string'));
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function pushbutton1_Callback(hObject, eventdata, handles)
plot(a,b,'r*')
两个文本框中输入坐标,按钮后画出图,请问哪里有错? 展开
1个回答
展开全部
因为a,b不是全局变量,所以把以下两句从edit控件的响应中剪切
a=num2double(get(handles.edit1,'string'));
b=num2double(get(handles.edit2,'string'));
粘贴到pushbutton的响应里
即
function pushbutton1_Callback(hObject, eventdata, handles)
a=num2double(get(handles.edit1,'string'));
b=num2double(get(handles.edit2,'string'));
plot(a,b,'r*')
a=num2double(get(handles.edit1,'string'));
b=num2double(get(handles.edit2,'string'));
粘贴到pushbutton的响应里
即
function pushbutton1_Callback(hObject, eventdata, handles)
a=num2double(get(handles.edit1,'string'));
b=num2double(get(handles.edit2,'string'));
plot(a,b,'r*')
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询