天天看点

【数字信号去噪】基于matlab粒子滤波器与FBS、MAP平滑方法数字信号去噪【含Matlab源码 2179期】

一、平滑分解简介

根据奈奎斯特定理,采样频率必须大于等于有用信号最高频率的2倍。假设对心电信号的采样满足奈奎斯特采样定理,则实测信号采样频率的1/2为有用心电信号的最高频率。通过三点平滑滤波,可以将频率大于1/2采样频率的信号滤除,将滤除的信号定义为第1阶平滑分解分量(sdc1)。而剩余信号中的最高频率则为前一阶提取频率的下限。继续按剩余信号最高频率的1/2进行新的平滑滤波提取,平滑滤波点数为前一级平滑滤波点数的2倍减1。直到平滑点数大于1/2数据长度且小于数据长度时分解结束。平滑分解方法描述如下。

设实际检测到的心电信号为s(n),n=1,2,…,N为样本序号,N为信号长度。记第k阶平滑分解分量为sdck(n),剩余信号记为rk(n),k=1,2,…,M。M=int(lb2(N-1))为最大分解阶数。

1)当k=1时

【数字信号去噪】基于matlab粒子滤波器与FBS、MAP平滑方法数字信号去噪【含Matlab源码 2179期】

2)当k≥2时

【数字信号去噪】基于matlab粒子滤波器与FBS、MAP平滑方法数字信号去噪【含Matlab源码 2179期】

在以上各式中,当i<1或i>N时,s(i)和rk-1(i)取相应的数据端点值。

  1. 信号重构
  2. 【数字信号去噪】基于matlab粒子滤波器与FBS、MAP平滑方法数字信号去噪【含Matlab源码 2179期】

二、部分源代码

close all
 T=100; %Number of Time Steps
 n=10; %Number of Particles
 m=1; %Number of iterationsfor iter=1:m
 %Mean and standard deviation of state equation
 a=.6; b=.2;
 %Mean and standard deviation of state equation
 c=2; d=.2;%Simulate the dynamical system x and y, initializing x(1)=x0
 x0=rand;
 [x,y]=simulate(a,b,c,d,x0,T);%Particle Filter, particles initialized at xf(:,1)=X0
 X0=random(‘uniform’,0,1,n,1);
 tic
 [xf,wftilda]=pfilter(a,b,c,d,X0,y);
 toc%Particle Smoothing (FBS)
 tic
 [wstilda wstilda2,wstilda3]=fbssmoother(a,b,xf,wftilda);
 toc%Particle Smoother (Maximum A-posterior) initialized at xf(:,1)=X20
 %Initialization
 X20=zeros(n,1);
 tic
 [psi,delta,meanm,wstilda4,wstilda5]=mapsmoother(a,b,c,d,X20,xf,wftilda,y);
 toc%Estimation of filter and fbs smoother posterior means at time t
 for t=2:T
 meanf(t)=xf(:,t)‘*wftilda(:,t);
 means(t)=xf(:,t)’*wstilda(:,t);
 meansf(t)=xf(:,t)'*wstilda(:,t);
 end%Computes the MSE of filter, fbs, and map
 FilterMSE(iter)=norm(x(2:end)-meanf(2:end),‘fro’)/norm(x(2:end),‘fro’)
 FBSsmootherMSE(iter)=norm(x(2:end)-means(2:end),‘fro’)/norm(x(2:end),‘fro’)
 MAPsmootherMSE(iter)=norm(x(2:end)-meanm(2:end),‘fro’)/norm(x(2:end),‘fro’)
 %Computes the Likelihood of filter, fbs, and map
 LL(iter)=likelihood(y,x,a,b,c,d)
 FilterLL(iter)=likelihood(y,meanf,a,b,c,d)
 FBSsmootherLL(iter)=likelihood(y,means,a,b,c,d)
 MAPsmootherLL(iter)=likelihood(y,meanm,a,b,c,d)
 endif m==1
 %Plots of simulated x vs the estimated xhat of filter, fbs, and map
 hold on
 plot(x(2:end),‘k’,‘linewidth’,2)
 plot(meanf(2:end),‘:r*’,‘linewidth’,2)
 plot(means(2:end),‘:go’,‘linewidth’,2)
 plot(meanm(2:end),‘:bd’,‘linewidth’,2)
 xlabel(‘time’)
 ylabel(‘state’)
 h = legend(‘True State’,‘Filter’,‘FBS-Smoother’,‘MAP-Smoother’);
 else
 fmean=mean(FilterMSE)
 smean=mean(FBSsmootherMSE)
 mmean=mean(MAPsmootherMSE)
 fll=mean(FilterLL)
 sll=mean(FBSsmootherLL)
 mll=mean(MAPsmootherLL)
 end      

三、运行结果

【数字信号去噪】基于matlab粒子滤波器与FBS、MAP平滑方法数字信号去噪【含Matlab源码 2179期】

四、matlab版本及参考文献

1 matlab版本

2014a

继续阅读