⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seril2.m

📁 matlab通过串口采集心电的GUI程序
💻 M
📖 第 1 页 / 共 2 页
字号:
%项目:本程序用于心电图机的上位机程序,用于心电图的显示
%版本:version 4
%修改:加入了50Hz的陷波器(version 3),成功生成exe文件,通过测试
%修改日期:2008.3.29  12:27    陈刚
function varargout = seril2(varargin)
% SERIL2 M-file for seril2.fig
%      SERIL2, by itself, creates a new SERIL2 or raises the existing
%      singleton*.
%
%      H = SERIL2 returns the handle to a new SERIL2 or the handle to
%      the existing singleton*.
%
%      SERIL2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SERIL2.M with the given input arguments.
%
%      SERIL2('Property','Value',...) creates a new SERIL2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before seril2_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to seril2_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help seril2

% Last Modified by GUIDE v2.5 17-Feb-2008 19:48:59

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @seril2_OpeningFcn, ...
                   'gui_OutputFcn',  @seril2_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before seril2 is made visible.
function seril2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to seril2 (see VARARGIN)

% Choose default command line output for seril2
handles.output = hObject;
global s_port;
global str_com;
global str_baudrate;
global str_databit;
global str_stopbit;
global a_coef;
global b_coef;
%设置下拉项目
str_com=char('com1','com2','com3','com4');
set(handles.popupmenu_com,'string',str_com);
str_baudrate=char('300','600','1200','2400','4800','9600','19200','38400','43000','56000','57600','115200');
set(handles.popupmenu_BaudRate,'string',str_baudrate);
str_parity=char('none','奇检验','偶检验');
set(handles.popupmenu_Parity,'string',str_parity);
str_databit=char('8','7','6');
set(handles.popupmenu_DataBit,'string',str_databit);
str_stopbit=char('1','2');
set(handles.popupmenu_StopBit,'string',str_stopbit);
% 创建端口
s_port=serial('com1');
% %打开设备
s_port.InputBufferSize=1024;
s_port.Timeout=10;
s_port.Terminator='LF';
% %设置50Hz陷波器
% wp=[48.5,51.5];
% wbs=[49.5,50.5];
% f0=50;
% fs=500;
% Amax=1;Amin=20;
% [n,wn]=buttord(wp/(fs/2),wbs/(fs/2),Amax,Amin);
% [b_coef,a_coef]=butter(n,wn,'stop');
a_coef=[1,-4.81029265000367,10.6587980454942,-13.5695363321212,10.4669278761242,-4.63866993354599,0.946963772978743];
b_coef=[0.973120636398519,-4.72389674344492,10.5632242108992,-13.5707054287793,10.5632242108992,-4.72389674344492,0.973120636398519];
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes seril2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = seril2_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes during object creation, after setting all properties.
function popupmenu_com_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu_com (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu_com.
function popupmenu_com_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_com (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu_com contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu_com
global s_port;
global str_com;
s_port.Port=str_com(get(handles.popupmenu_com,'value'),:);
% --- Executes during object creation, after setting all properties.
function popupmenu_BaudRate_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu_BaudRate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu_BaudRate.
function popupmenu_BaudRate_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_BaudRate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu_BaudRate contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu_BaudRate
global s_port;
global str_baudrate;
s_port.BaudRate=str2num(str_baudrate(get(handles.popupmenu_BaudRate,'value'),:));

% --- Executes during object creation, after setting all properties.
function popupmenu_Parity_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu_Parity (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu_Parity.
function popupmenu_Parity_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_Parity (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu_Parity contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu_Parity
global s_port;
str_parity_temp=char('none','odd','even');
s_port.Parity=str_parity_temp(get(handles.popupmenu_Parity,'value'),:);

% --- Executes during object creation, after setting all properties.
function popupmenu_DataBit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu_DataBit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu_DataBit.
function popupmenu_DataBit_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_DataBit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu_DataBit contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu_DataBit
global s_port;
global str_databit;
s_port.DataBit=str2num(str_databit(get(handles.popupmenu_DataBit,'value'),:));

% --- Executes during object creation, after setting all properties.
function popupmenu_StopBit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu_StopBit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu_StopBit.
function popupmenu_StopBit_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_StopBit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu_StopBit contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu_StopBit
global s_port;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -