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

📄 bat1.m

📁 编程实现基于小波变换尺度相关性去噪算法
💻 M
字号:
function bat1%非正交的二次样条二进小波h = [0 0 0.125 0.375 0.375 0.125 0 0].*sqrt(2);g = [0 0 0 -1 1 0 0 0].*sqrt(2);g1 = [0 0.015625 0.109375 0.34375 -0.34375 -0.109375 -0.015625 0].*sqrt(2);%正交的二次样条二进小波% h = [0 0 0 0 0.375 0.125 0.373].*sqrt(2);% g = [0 0 0 0 0.5798 0.0869 0.0061].*sqrt(2);%g1 = [0 0.015625 0.109375 0.34375 -0.34375 -0.109375 -0.015625 0].*sqrt(2);%正交的三次样条二进小波% h = [0 0.0625 0.2500 0.3750 0.2500 0.0625 0].*sqrt(2);% g = [-0.00008 -0.01643 -0.10872 -0.59261 0 0.59261 0.10872 0.01643 0.00008].*sqrt(2);%g1 = [0 0.015625 0.109375 0.34375 -0.34375 -0.109375 -0.015625 0].*sqrt(2);l = 512;x = [1:l];% s0 = sin(2*pi*x/l*4).*sin(2*pi*x/l*8).*sin(2*pi*x/l)*10;% s = s0+rand(1,l)*2;% s = sin(2*pi*x/l*2);s(1:l/4) = 2;s(l/4+1:l*1/2) = 5;s(l*1/2+1:l*3/4) = 3;s(l*3/4+1:l) = 4;% s(1:l/4) = [1:l/4]./20 + l/8/20;% s(l/4+1:l*1/2) = s(l/4:-1:1);% s(l/2+1:l) = s(1:l/2);n = 7;[a d] = swt1d_decomp(s,n,h,g);% figure,title('原始信号')% plot(s);% [Y I] = max(s);% Ifigure, title('逼近矩阵');for i=1:n    subplot(n,1,i);    title(['逼近矩阵 ' num2str(i)]);    plot(a(:,i));    set(gca,'XTick',0:50:l);%     [Y I] = max(a(:,i));%     Iendsaveas(gcf,['pic' filesep 'a'],'png'),close(gcf);figure, title('细节信息矩阵');for i=1:n    subplot(n,1,i);    title(['细节矩阵 ' num2str(i)]);    plot(d(:,i));    set(gca,'XTick',0:50:l);endsaveas(gcf,['pic' filesep 'd'],'png'),close(gcf);% 重构s1 = swt1d_recon(a,d,n,h,g1);ss = s1(:,[2:n+1]);row = ceil(sqrt(n));col = ceil(n/row);figure, title('重构矩阵');for i=1:n    subplot(n,1,i);    title(['重构矩阵' num2str(n-i+1)]);    plot(ss(:,n-i+1));    set(gca,'XTick',0:50:l);%         [Y I] = max(ss(:,n-i+1));%         Iendsaveas(gcf,['pic' filesep 'reconst'],'png'),close(gcf);sr = ss(:,n);figuresubplot(3,1,1), hold on, title('原始信号'),plot(s), set(gca,'XTick',0:50:l);subplot(3,1,2), hold on, title('重构信号'),plot(sr), set(gca,'XTick',0:50:l);subplot(3,1,3), hold on, title('误差信号'),plot(sr-s'),set(gca,'XTick',0:50:l);saveas(gcf,['pic' filesep 'result'],'png'),close(gcf);%     [Y I] = max(sr);%     I% figure;% for i=1:n%     subplot(n,1,i);%     title(['重构矩阵误差' num2str(n-i+1)]);%     sr = ss(:,n-i+1);%     so = a(:,i);%     plot(sr-so);%     set(gca,'XTick',1:10:l);% end

⌨️ 快捷键说明

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