梅梅
2008-05-10, 17:58
大侠们帮忙看看,哪里有问题......
function boundsedit_Callback(hObject, eventdata, handles)
% hObject handle to boundsedit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of boundsedit as text
% str2double(get(hObject,'String')) returns contents of boundsedit as a double
global bounds1;
bounds1 = str2double(get(hObject,'string'));
if isnan(bounds1)
errordlg('You must enter a numeric value','Bad Input','modal')
end
........
function boundsedit2_Callback(hObject, eventdata, handles)
% hObject handle to boundsedit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of boundsedit2 as text
% str2double(get(hObject,'String')) returns contents of boundsedit2 as a double
global bounds2;
bounds2 = str2double(get(hObject,'string'));
if isnan(bounds2)
errordlg('You must enter a numeric value','Bad Input','modal')
end
............
function OKpushbutton_Callback(hObject, eventdata, handles)
% hObject handle to OKpushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global bounds;
bounds = [];
bounds = [bounds1,bounds2];
disp(bounds);
......
运行结果::??? Undefined function or variable 'bounds1'.
Error in ==> GA_user>OKpushbutton_Callback at 328
bounds = [bounds1,bounds2];
Error in ==> gui_mainfcn at 75
feval(varargin{:});
Error in ==> GA_user at 44
gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback.
这是为什么啊?已经申明了global,怎么还是不能访问到bounds1,bounds2 阿??/
function boundsedit_Callback(hObject, eventdata, handles)
% hObject handle to boundsedit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of boundsedit as text
% str2double(get(hObject,'String')) returns contents of boundsedit as a double
global bounds1;
bounds1 = str2double(get(hObject,'string'));
if isnan(bounds1)
errordlg('You must enter a numeric value','Bad Input','modal')
end
........
function boundsedit2_Callback(hObject, eventdata, handles)
% hObject handle to boundsedit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of boundsedit2 as text
% str2double(get(hObject,'String')) returns contents of boundsedit2 as a double
global bounds2;
bounds2 = str2double(get(hObject,'string'));
if isnan(bounds2)
errordlg('You must enter a numeric value','Bad Input','modal')
end
............
function OKpushbutton_Callback(hObject, eventdata, handles)
% hObject handle to OKpushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global bounds;
bounds = [];
bounds = [bounds1,bounds2];
disp(bounds);
......
运行结果::??? Undefined function or variable 'bounds1'.
Error in ==> GA_user>OKpushbutton_Callback at 328
bounds = [bounds1,bounds2];
Error in ==> gui_mainfcn at 75
feval(varargin{:});
Error in ==> GA_user at 44
gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback.
这是为什么啊?已经申明了global,怎么还是不能访问到bounds1,bounds2 阿??/