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

📄 daubcomp.m

📁 应用小波进行压缩和滤波的matlab程序.程序选用Daubechies的仅4个系数的小波函数
💻 M
字号:
% 应用小波压缩和滤波.
% 应用小波工具箱分解信号.压缩分解信号然后又重构.该程序使用了两个关键的MATLAB命令wavedec和waverec分别用于分解和重构.
% 本程序可使用不同的小波基.此处使用了Daubechies的仅4个系数的小波(表示为db2小波).也可使用更高级数的Daubechies小波(表示为dbn,这里的n是从1到50的整数,n=1即Haar小波).
% 程序的输入是信号y,相应的时间标记t,分解层数n和压缩率r.
% 本程序输出原信号曲线,压缩信号曲线以及相对l*l误差曲线.

function error=daubcomp(t,y,n,r)
% Input is an array y, which represents a digitized signal associated with the vector t;
% n=the numberof levels (so the number of nodes is 2^n=length of t and the length of y).
% Also input r which is a decimal numberbeween 0 and 1 representing the compression rate
% e.g. 80 percent would be r=0.8.
% Output are the graphs of y and its copression, as well as the relative error. This routine uses compress.m and Daubechies -4 wavelets.

if (r<0)|(r>1)
    error ('r should be between 0 and 1')
end;
[c,l]=wavedec(y,n,'db2'); % MATLAB's wave decomposition rutine 
cc=compress(c,r);         % compress the signal
yc=waverec(cc,l,'db2');   % MATLAB's wave reconstruction rutine 
subplot(2,2,1);
plot(t,y)  
subplot(2,2,2);
plot(t,cc)
subplot(2,2,3);
plot(t,yc)
subplot(2,2,4);
plot(t,y,t,yc)            % plot of the signal and compressed signal
error=norm(y-yc,2)/norm(y); % relative 1^2 error

⌨️ 快捷键说明

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