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

📄 examp16_1.m

📁 《小波分析理论与Matlab7实现例程》一书里面各章节的源码
💻 M
字号:
clc;
clear;
%生成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('时间 t/s');ylabel('(sig1)幅值 A');
axis([0 1200 -2 2]);
subplot(3,1,2);plot(t,x2,'LineWidth',2);
%xlabel('时间 t/s');ylabel('(sig2)幅值 A');
axis([0 1200 -2 2]);
subplot(3,1,3);plot(t,x3,'LineWidth',2);
xlabel('时间 t/s');ylabel('(sig3)幅值 A');
axis([0 1200 -2 2]);
%叠加信号
x=x1+x2+x3;
xx=wextend(1,'ppd',x,20);
N1=N+2*20;
t1=1:N1;
figure(2)
subplot(211);plot(t,x,'LineWidth',2);xlabel('时间 t/s');ylabel('幅值 A');
subplot(212);plot(t1,xx,'linewidth',2);xlabel('时间 t/s');ylabel('幅值 A');
%一维小波分解
[c,l] = wavedec(xx,5,'db3');
%重构第1~5层逼近信号
a5 = wrcoef('a',c,l,'db3',5);
a4 = wrcoef('a',c,l,'db3',4);
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);ylabel('a5');
subplot(5,1,2);plot(a4,'LineWidth',2);ylabel('a4');
subplot(5,1,3);plot(a3,'LineWidth',2);ylabel('a3');
subplot(5,1,4);plot(a2,'LineWidth',2);ylabel('a2');
subplot(5,1,5);plot(a1,'LineWidth',2);ylabel('a1');
xlabel('时间 t/s');
%重构第1~5层细节信号
d5 = wrcoef('d',c,l,'db3',5);
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(d5,'LineWidth',2);ylabel('d5');
subplot(5,1,2);plot(d4,'LineWidth',2);ylabel('d4');
subplot(5,1,3);plot(d3,'LineWidth',2);ylabel('d3');
subplot(5,1,4);plot(d2,'LineWidth',2);ylabel('d2');
subplot(5,1,5);plot(d1,'LineWidth',2);ylabel('d1');
xlabel('时间 t/s');

⌨️ 快捷键说明

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