|
楼主 |
发表于 2006-4-18 02:23
|
显示全部楼层
% 画出3个函数图像
N=1024;
t=1:N;
x1=sin(3*t);
x2=sin(0.3*t);
x3=sin(0.03*t);
figure(1);
subplot(3,1,1);plot(t,x1,'linewidth',2);
xlabel('x1=sin(3*t) 时间 t/s');
axis([0 1200 -1.5 1.5]);
subplot(3,1,2);plot(t,x2,'linewidth',2);
xlabel('x2=sin(0.3*t) 时间 t/s');
axis([0 1200 -1.5 1.5]);
subplot(3,1,3);plot(t,x3,'linewidth',2);
xlabel('x3=sin(0.03*t) 时间 t/s');
axis([0 1200 -1.5 1.5]);
% 3个函数叠加在一起
x=x1+x2+x3;
figure(2);
plot(t,x,'linewidth',2);
xlabel(' 3个函数叠加产生的信号 时间 t/s');ylabel(' 幅值A');
% x信号在5层小波分解
[c,l]=wavedec(x,5,'db3'); %[c,l]=wavedec(x,5,'db3') 返回信号x在5层上的小波分解
% 重构1-5层的逼近信号
a5=wrcoef('a',c,l,'db3',5); %a5=wrcoef('a',c,l,'db3',5) 基于小波分解结构[c,l]在5层计算重构系数向量。'type'='a' 指重构系数是低频
a4=wrcoef('a',c,l,'db3',4); %其中的5,4,3,2,1为N,必须严格正整数,而且N<=length(L)-2,'type'='a'时候,N可以为0
a3=wrcoef('a',c,l,'db3',3);
a2=wrcoef('a',c,l,'db3',2);
a1=wrcoef('a',c,l,'db3',1);
figure(3);
subplot(5,1,1);plot(a5,'linewidth',2);xlabel('a5=wrcoef("a",c,l,"db3",5);');ylabel(' a5');
subplot(5,1,2);plot(a4,'linewidth',2);xlabel('a4=wrcoef("a",c,l,"db3",4);');ylabel(' a4');
subplot(5,1,3);plot(a3,'linewidth',2);xlabel('a3=wrcoef("a",c,l,"db3",3);');ylabel(' a3');
subplot(5,1,4);plot(a2,'linewidth',2);xlabel('a2=wrcoef("a",c,l,"db3",2);');ylabel(' a2');
subplot(5,1,5);plot(a1,'linewidth',2);xlabel('a1=wrcoef("a",c,l,"db3",1);');ylabel(' a1');
xlabel('时间 t/s');
%重构1-4层的细节信号
d5=wrcoef('d',c,l,'db3',5); %'type'='d' 指重构系数是高频
d4=wrcoef('d',c,l,'db3',4);
d3=wrcoef('d',c,l,'db3',3);
d2=wrcoef('d',c,l,'db3',2);
d1=wrcoef('d',c,l,'db3',1);
figure(4);
subplot(5,1,1);plot(t,d5,'linewidth',2);xlabel('d5=wrcoef("d",c,l,"db3",5);');ylabel(' d5');
subplot(5,1,2);plot(t,d4,'linewidth',2);xlabel('d4=wrcoef("d",c,l,"db3",5);');ylabel(' d4');
subplot(5,1,3);plot(t,d3,'linewidth',2);xlabel('d3=wrcoef("d",c,l,"db3",5);');ylabel(' d3');
subplot(5,1,4);plot(t,d2,'linewidth',2);xlabel('d2=wrcoef("d",c,l,"db3",5);');ylabel(' d2');
subplot(5,1,5);plot(t,d1,'linewidth',2);xlabel('d1=wrcoef("d",c,l,"db3",5);');ylabel(' d1');
xlabel('时间 t/s');
% x1=sin(3*t)与d1作比较
bj1=x1-d1;
figure(5);
subplot(3,1,1);plot(t,d1,'linewidth',2);xlabel('d1=wrcoef("d",c,l,"db3",5); 时间 t/s');
axis([0 1200 -2 2]);
subplot(3,1,2);plot(t,x1,'linewidth',2);xlabel('x1=sin(3*t) 时间 t/s');
axis([0 1200 -2 2]);
subplot(3,1,3);plot(t,bj1,'linewidth',2);
axis([0 1200 -.2 .2]);
% bj1的输出结果表明,x1=d1
% x2=sin(.3*t)与a4作比较
bj2=x2-d4;
figure(7);
subplot(3,1,1);plot(t,d4,'linewidth',2);xlabel('d4=wrcoef("d",c,l,"db3",4); 时间 t/s');
axis([0 1200 -2 2]);
subplot(3,1,2);plot(t,x2,'linewidth',2);xlabel('x2=sin(.3*t) 时间 t/s');
axis([0 1200 -2 2]);
subplot(3,1,3);plot(t,bj2,'linewidth',2);
axis([0 1200 -.5 .5]);
% bj2的输出结果表明,x2=d4
% x3=sin(.03*t)与a4作比较
bj3=x3-a4;
figure(6);
subplot(3,1,1);plot(t,a4,'linewidth',2);xlabel('a4=wrcoef("a",c,l,"db3",4); 时间 t/s');
axis([0 1200 -2 2]);
subplot(3,1,2);plot(t,x3,'linewidth',2);xlabel('x3=sin(.03*t) 时间 t/s');
axis([0 1200 -2 2]);
subplot(3,1,3);plot(t,bj3,'linewidth',2);
axis([0 1200 -.5 .5]);
% bj3的输出结果表明,x3=a4
我想用MATLAB7.0的小波工具箱完成这个程序的操作..
{程序原创..各位见笑} |
|