ecgsim.m

来自「很多matlab的源代码」· M 代码 · 共 41 行

M
41
字号
function y = ecgsim(N,m)
%ECG	simulated ECG waveform
%	y=ecgsim(N,m)  generates simulated ECG with 100N points per beat
%	using an m-point triangular window for smoothing out the edges. 
% 	N must be an integer. Default: N=1
% 	m must be odd. Default m=9
%
% 	If no input arguments, we invoke the following example:
%	Generate a simulated ecg + 60 Hz noise, then filter using notch filter
%
%	>> y1=ecgsim(6,9);t1=(0:599)/600;y1=y1+cos(2*pi*60*t1);
%	>> tt=[t1 t1+1 t1+2];yy=[y1 y1 y1];[n,d]=blt2ord('bs',600,1,60);
%	>> yf=filter(n,d,yy);subplot(211),plot(tt,yy),subplot(212),plot(tt,yf)


% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998



if nargin==0,help ecgsim,disp('strike a key to continue'),pause
yo=ecgsim(6,9);t1=(0:599)/600;y1=yo+cos(2*pi*60*t1);
tt=[t1 t1+1 t1+2];yy=[y1 y1 y1];[n,d]=blt2ord('bs',600,1,60);
yf=filter(n,d,yy);subplot(211),plot(tt,yy),
subplot(212),plot(tt,yf,tt,[yo yo yo]),return,end

if nargin < 2, m=9;end
if nargin < 1, N=1;end
t=0:100*N-1;

y1=0.4*tri((t-16*N)/6/N)-0.4*tri((t-32*N)/N/2)+1.8*tri((t-36*N)/4/N)-0.6*tri((t-42*N)/N/2)+0.6*tri((t-72*N)/8/N);

y=filtfilt(window('bart',m),1,y1);
y=1.8*y/max(y);

⌨️ 快捷键说明

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