?? a39.m
字號:
load noisdopp; %裝載信號
s = noisdopp;
[swa,swd] = swt(s,1,'db1'); %完成信號的單尺度一維離散平穩小波分解
whos
figure(1);
subplot(1,2,1), plot(swa); %顯示低頻和高頻部分
title('Approximation cfs')
subplot(1,2,2), plot(swd);
title('Detail cfs')
A0 = iswt(swa,swd,'db1'); %由平穩小波逆變換重構信號
err=norm(s-A0) %查看重構誤差
nulcfs = zeros(size(swa)); %從系數構建低頻和高頻部分
A1 = iswt(swa,nulcfs,'db1');
D1 = iswt(nulcfs,swd,'db1');
figure(2);
subplot(1,2,1), plot(A1); %顯示低頻和高頻部分
title('Approximation A1');
subplot(1,2,2), plot(D1);
title('Detail D1');
[swa,swd] = swt(s,3,'db1'); %多層平穩小波分解
clear A0 A1 D1 err nulcfs %觀察swa和swd的結構
whos
kp = 0; %顯示低頻和高頻系數
figure(3);
for i = 1:3
subplot(3,2,kp+1), plot(swa(i,:));
title(['Approx. cfs level ',num2str(i)])
subplot(3,2,kp+2), plot(swd(i,:));
title(['Detail cfs level ',num2str(i)])
kp = kp + 2;
end
mzero = zeros(size(swd)); %從系數重構第三層的低頻信號
A = mzero;
A(3,:) = iswt(swa,mzero,'db1');
D = mzero; %重構第1、2、3層的高頻信號
for i = 1:3
swcfs = mzero;
swcfs(i,:) = swd(i,:);
D(i,:) = iswt(mzero,swcfs,'db1');
end
A(2,:) = A(3,:) + D(3,:); %從第三層的低頻部分和第二、三層的高頻部分重構第一、二層的低頻部分%
A(1,:) = A(2,:) + D(2,:);
kp = 0; %顯示第一、二、三層的低頻和高頻部分
figure(4);
for i = 1:3
subplot(3,2,kp+1), plot(A(i,:));
title(['Approx. level ',num2str(i)])
subplot(3,2,kp+2), plot(D(i,:));
title(['Detail level ',num2str(i)])
kp = kp + 2;
end
[thr,sorh] = ddencmp('den','wv',s); %去除信號中的噪聲
dswd = wthresh(swd,sorh,thr);
clean = iswt(swa,dswd,'db1');
figure(5);
subplot(2,1,1), plot(s); %顯示原始信號和去除了噪聲的信號
title('Original signal')
subplot(2,1,2), plot(clean);
title('De-noised signal')
[swa,swd] = swt(s,5,'db1'); %將原來的三層次的分解改為五層次的分解并重復上面的步驟
[thr,sorh] = ddencmp('den','wv',s);
dswd = wthresh(swd,sorh,thr);
clean = iswt(swa,dswd,'db1');
figure(6);
subplot(2,1,1), plot(s); title('Original signal')
subplot(2,1,2), plot(clean); title('De-noised signal')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -