Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
 
 
主题工具 显示模式
旧 2008-05-29, 12:45   #1
jojocleo
初级会员
 
注册日期: 2008-03-06
年龄: 43
帖子: 2
声望力: 0
jojocleo 正向着好的方向发展
默认 [求助][讨论]GUI中不同控件间实时数据传递问题

我现在做了个GUI界面,需要在其中的两个控件中进行实时数据传递,就是控件1的数据是个变量,随时间变化,而控件2需要这个变量的值进行判断。但是我在运行控件2的时候控件1的命令就会停止,控件2调用的这个变量也就不随时间变化了,这个问题怎么解决?我把一个简单的程序附上,大家看看。
function display_Callback(hObject, eventdata, handles)
% hObject handle to display (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
for i=1:1000
set(handles.edit_output,'string',num2str(i));
setappdata(handles.figure1,'angle',i);
pause(0.2)
end
%----------
function edit_output_Callback(hObject, eventdata, handles)
% hObject handle to edit_output (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 edit_output as text
% str2double(get(hObject,'String')) returns contents of edit_output
% as a double
%-----------
function send_Callback(hObject, eventdata, handles)
% hObject handle to send (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% global angle
global s
% a=get(handles.edit_input,'string');
% fwrite(s,a); %向com1口发送两个数据48和59
for i=1:100
getappdata(handles.figure1,'angle')
pause(0.2)
end
%-----------
output是显示窗口,把display中的变量i显示出来,i随时间变化,同时把i传递给send控件,运行send控件时,会使display中的命令停止。
jojocleo 当前离线   回复时引用此帖
 


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码



所有时间均为北京时间。现在的时间是 12:12


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.