![]() |
GUI 参数调用问题
大侠们帮忙看看,哪里有问题......
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 阿??/ |
差不多
我和你的问题差不多,只要你要调用某个全局变量,你就必须用global在之前在短衣一次,即调用变量时,还要定义一下。不知我说明白没?
|
明白了,后来解决了,这样真麻烦.........
还是谢谢你哈........ |
hao o:biggrin:
|
回复: 差不多
[QUOTE=hualiangzi;9761]我和你的问题差不多,只要你要调用某个全局变量,你就必须用global在之前在短衣一次,即调用变量时,还要定义一下。不知我说明白没?[/QUOTE]
非常感谢!我的问题也解决了! |
所有时间均为北京时间。现在的时间是 07:01。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.