|
楼主 |
发表于 2005-12-6 09:42
|
显示全部楼层
回复:(wsi)[转帖]小波变换的模极大值重建信号源程序...
function [signal,swa,swd,ddw,wpeak]=wave_peak(points,level,Lo_D,Hi_D,Lo_R,Hi_R,offset)<BR>% 该函数用于读取ecg信号,找到小波变换模极大序列<BR><BR>warning off;<BR>ecgdata=load('ecg.txt' );<BR>plot(ecgdata(1:points)),grid on,axis tight,axis([1,points,-50,300]);<BR>signal=ecgdata(1:points)'+offset;<BR><BR>% 信号的小波变换,按级给出概貌和细节的波形<BR>[swa,swd] = swt(signal,level,Lo_D,Hi_D);<BR>figure;<BR>subplot(level,1,1); plot(real(signal)); grid on;axis tight;<BR>for i=1:level<BR>subplot(level+1,2,2*(i)+1);<BR>plot(swa(i,: )); axis tight;grid on;xlabel('time');<BR>ylabel(strcat('a ',num2str(i)));<BR>subplot(level+1,2,2*(i)+2);<BR>plot(swd(i,: )); axis tight;grid on;<BR>ylabel(strcat('d ',num2str(i)));<BR>end<BR><BR>%求小波变换的模极大值及其位置<BR>ddw=zeros(size(swd));<BR>pddw=ddw;<BR>nddw=ddw;<BR>posw=swd.*(swd>0);<BR>pdw=((posw(:,1:points-1)-posw(:,2:points))<0);<BR>pddw(:,2:points-1)=((pdw(:,1:points-2)-pdw(:,2:points-1))>0);<BR>negw=swd.*(swd<0);<BR>ndw=((negw(:,1:points-1)-negw(:,2:points))>0);<BR>nddw(:,2:points-1)=((ndw(:,1:points-2)-ndw(:,2:points-1))>0);<BR>ddw=pddw|nddw;<BR>ddw(:,1)=1;<BR>ddw(:,points)=1;<BR>wpeak=ddw.*swd;<BR>wpeak(:,1)=wpeak(:,1)+1e-10;<BR>wpeak(:,points)=wpeak(:,points)+1e-10;<BR><BR>%按级给出小波变换模极大的波形<BR>figure;<BR>for i=1:level<BR>subplot(level,1,i);<BR>plot(wpeak(i,: )); axis tight;grid on;<BR>ylabel(strcat('j= ',num2str(i)));<BR>end <BR> |
评分
-
1
查看全部评分
-
|