📄 ecg_dis.m
字号:
function ecg_dis % persistent ss;% ss = scom;% scom=serial('COM1','BaudRate',19200,'Parity','none','DataBits',8,'StopBits',1);% fopen(scom);clear all % Create and then hide the GUI as it is being constructed. f = figure('Visible','off','Position',[360,500,1300,800]); % Construct the components. hstart = uicontrol('Style','pushbutton','String','Start',... 'Position',[900,600,70,25],... 'Callback',{@Start_Callback}); hstop = uicontrol('Style','pushbutton',... 'String','stop',... 'Position',[900,540,70,25],... 'Callback',{@Stop_Callback}); hsave = uicontrol('Style','pushbutton','String','Save',... 'Position',[900,480,70,25],... 'Callback',{@Save_Callback}); hredis = uicontrol('Style','pushbutton','String','Redisplay',... 'Position',[870,380,70,25],... 'Callback',{@Redis_Callback}); hupload =uicontrol('Style','pushbutton','String','Upload',... 'Position',[870,320,70,25],... 'Callback',{@upload_Callback}); hquit = uicontrol('Style','pushbutton','String','Quit',... 'Position',[870,260,70,25],... 'Callback',{@Quit_Callback}); ha = axes('Units','Pixels','Position',[30,180,800,500]); align([hstart,hstop,hsave],'Center','None'); % Create the data to plot. persistent x; persistent y; persistent N;% persistent m; N=500; m=10; x=1:N; y=0*x; % Initialize the GUI. % Change units to normalized so components resize % automatically. set([f,ha,hstart,hstop,hsave],... 'Units','normalized'); %Create a plot in the axes. h = plot(x,y,'erasemode','xor','color','b','linewidth',1); title('ECG monitor system'); grid on; axis([1,N,-50,200]); % Assign the GUI a name to appear in the window title. set(f,'Name','ECG display') % Move the GUI to the center of the screen. movegui(f,'center') % Make the GUI visible. set(f,'Visible','on'); function Start_Callback(source,eventdata) while true % A=fread(scom,[1,m]);%read from com% y=[A,y(1:N-m)]; set(h,'xdata',x,'ydata',y); drawnow end end function Stop_Callback(source,eventdata) waitfor(hstart); end function Save_Callback(source,eventdata) B=zeros(1,2640); for i=1:10 B(264*i-263:264*i)=fread(scom,[1,264]); end save ecg_d.mat B; end function Redis_Callback(source,eventdata)% load ecg_d.mat B; fid=fopen('100.dat','r'); B=fread(fid, inf, 'schar'); BB=zeros(1,1200); while true for i=1:120 BB=[B(i*10-9:i*10),BB(1:1190)]; set(h,'xdata',x,'ydata',BB); drawnow pause(0.025); end end end function upload_Callback(source,eventdata) M = 2047;% C=fread(scom,1); while C~=85% fwrite(scom,85);% C=fread(scom,1); end D=zeros(1,M*264); for i=1:M D(264*i-263:264*i)=fread(scom,[1,264]); end save ecg_f.mat D; end function Quit_Callback(source,eventdata)% fclose(scom);%关闭串口设备对象% delete(scom);%删除内存中的串口设备对象 close all; end end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -