楼主要的是不是这个?
figure(1)
fs=2000; t=0:1/fs:1;
for i=1:length(t)
if t(i)<=0.2
x(i)=8*sin(60*pi*t(i)+pi/12)+6*sin(240*pi*t(i)+pi/2)+sin(300*pi*t(i)+pi/6);
else
x(i)=8*sin(60*pi*t(i)+pi/12)+6*sin(240*pi*t(i)+pi/2)+sin(300*pi*t(i)+pi/6)+20*sin(500*pi*t(i)+pi/3).*exp(-20*(t(i)-0.2));
end
end
plot(t,x); grid on
figure(2)
wpt=wpdec(x,4,'db3'); plot(wpt);
for i=0:15
figure(3); rfs=wprcoef(wpt,[4 i]);
subplot(4,4,i+1);
plot(rfs); grid on; title(['[4 ',num2str(i),']']); axis([0 2000 min(rfs) max(rfs)]);
end
for i=0:3
figure(4); rfs=wprcoef(wpt,[4 i]);
subplot(4,1,i+1);
plot(rfs); grid on; title(['[4 ',num2str(i),']']); axis([0 2000 min(rfs) max(rfs)]);
end
for i=1:4
wpt=wpdec(x,i,'db3'); e=wenergy(wpt); E=zeros(1,length(e));
for j=1:2^i
E(j)=sum(abs(wprcoef(wpt,[i,j-1])).^2);
end
figure(5)
subplot(4,1,i);
bar(e); axis([0 length(e) 0 130]); title(['第 ',num2str(i), ' 层']);
for j=1:length(e)
text(j-0.2,e(j)+20,num2str(e(j),'%2.2f'));
end
end
[ 本帖最后由 ChaChing 于 2010-8-16 01:01 编辑 ] |