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

📄 qrs.m

📁 用matlab设计FIR和IIR滤波器的设计函数与例程
💻 M
字号:
clear;
filename='D:\mit\113-2.txt';
fid=fopen(filename,'r');
fs=250;
%[A,COUNT] = FSCANF(FID,FORMAT,SIZE)
[ecgdata,n]=fscanf(fid,'%d',2000);
fclose(fid);
ecg=ecgdata-mean(ecgdata);

%------------lp,截至频率11HZ,延迟5个采样点,增益36
a=[1 zeros(1,5)  -2 zeros(1,5) 1];b=36*[1 -2  1 zeros(1,10)];
ecgdata_denoise=filter(a,b,ecg);
 figure(1);subplot(2,1,1);plot(ecg(1:1000));title('orignal');
subplot(2,1,2);
plot(ecgdata_denoise(1:1000));title('LP');
 figure(2);
 freqz(a,b,512,fs);
%------------hp,截至频率fs/(2*32)=4HZ,延迟15.5个采样点,增益32
a=[ -1  zeros(1,15) 32 -32 zeros(1,15) 1];b=[32 -32 zeros(1,31)];
ecgdata_denoise1=filter(a,b,ecgdata_denoise);
 figure(3);
plot(ecgdata_denoise1(1:1000));title('高通滤波');grid on;
 figure(4);
 freqz(a,b,512,fs);
 %------------diff
a=[ 2 1 0 -1 -2];b=[10];
ecgdata_denoise2=filter(a,b,ecgdata_denoise1);
 figure(5);
 subplot(2,1,1);
 plot(ecgdata_denoise2(1:1000));title('diff');grid on;
 subplot(2,1,2);
 ecgdata_denoise3=ecgdata_denoise2.*ecgdata_denoise2;
plot(ecgdata_denoise3(1:1000));title('square');grid on;
 figure(6);
 freqz(a,b,512,fs);
 %-----------------------------sum 32p
 y=zeros(1,length(ecg)-30);
 for i=1:length(ecg)-30
     sum=0;
     for j=0:29
     sum=sum+ecgdata_denoise3(i+j);
     end
     y(i)=sum;
 end
 figure(7);
 plot(y(1:1000));grid on;
     

⌨️ 快捷键说明

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