How to create a multi thread gui
显示 更早的评论
Hello how can i plot data real time in a gui?
The code below keeps blocking.I want when i press the close_port_btn the reading to stop. Since i have seen there is no function to get the serial status of the port i created that flag. This flag is intended to stop the reading. Somehow it seems the code won't exit that part of code. Do i need to do multithreading? And if so how can i achieve that?
function read_btn_Callback(hObject, eventdata,handles)
% hObject handle to read_btn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global port;
fopen(port);
handles.flag=1;
N=100;
y=zeros(N,1);
t=linspace(0,N,1);
while (handles.flag~=0)
y(1:end-1)=y(2:end);
x=fscanf(port,'%d')/100
plot(y,'LineWidth',2);
grid on;
axis([0 100 0 50])
end
guidata(hObject,handles);
function close_port_btn_Callback(hObject, eventdata, handles)
% hObject handle to close_port_btn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global port;
fclose(port);
handles.flag=0;
guidata(hObject,handles);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!