对信号进行一层分解
clc;
clear;
% 获取噪声信号
load(‘matlab.mat‘);
sig = M(1,1:1400);
SignalLength = length(sig);
%使用db1分解1层
[cA1,cD1] = dwt(sig,‘db1‘);
%从系数 cA1 和 cD1 中构建一层近似A1 和细节 D1
A1 = upcoef(‘a‘,cA1,‘db1‘,1,SignalLength);
D1 = upcoef(‘d‘,cD1,‘db1‘,1,SignalLength);
% %或
% A1 = idwt(cA1,[],‘db1‘,l_s);
% D1 = idwt([],cD1,‘db1‘,l_s);
%显示近似和细节
subplot(1,2,1); plot(A1); title(‘Approximation A1‘)
subplot(1,2,2); plot(D1); title(‘Detail D1‘)
%使用逆小波变换恢复信号
A0 = idwt(cA1,cD1,‘db1‘,SignalLength);
err = m