资源描述:
《Mallat分解算法和合成算法程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Mallat分解算法%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%f1=50;%构造数据点的函数频率f2=100;fs=2*(f1+f2);%采样频率Ts=1/fs;%采样间隔N=120;%采样点数n=1:N;dec0=sin(2*pi*f1*n*Ts)+sin(2*pi*f2*n*Ts);%用两个正弦函数构
2、造数据点%——————————————定义的正弦波形形成的时域图以及频域图——————————————%figure(1)subplot(2,1,1)plot(dec0);title('两个余弦波混合形成的波形')subplot(2,1,2)stem(abs(fft(dec0)));title('混合信号的频域图')lowpass=wfilters('db30','l');%返回Daubechies小波的低通滤波器highpass=wfilters('db30','h');%返回Daubechies小波的高通滤波器lowpass=[lowpass,zeros(1,N-leng
3、th(lowpass))];%在数据点末尾补零到N点,方便后续卷积运算highpass=[highpass,zeros(1,N-length(highpass))];figure(2)subplot(2,1,1);stem(abs(fft(lowpass)));%画出低通滤波器的频域图xlabel('Hz');title('低通滤波器频域图');subplot(2,1,2);stem(abs(fft(highpass)));xlabel('Hz');title('高通滤波器频域图')dec1_low=ifft(fft(dec0).*fft(lowpass));%低频滤波dec
4、1_high=ifft(fft(dec0).*fft(highpass));%高频率波dec2_low=ifft(fft(dec1_low).*fft(lowpass));dec2_high=ifft(fft(dec1_low).*fft(highpass));%——————————————多次分解信号的是域图——————————————————%figure(3)subplot(2,2,1)plot(real(dec1_low));%画出第一次信号分解的低频分量title('第一次信号分解的低频分量时域图');subplot(2,2,2)plot(real(dec1_hig
5、h));title('第一次信号分解的高频分量时域图');subplot(2,2,3)plot(real(dec2_low));title('第二次信号分解的低频分量时域图');subplot(2,2,4)plot(real(dec2_high));title('第二次信号分解的高频分量时域图');%————————————————多次分解信号相对应的频域信号————————————%figure(4)subplot(2,2,1)stem(abs(fft(dec1_low)));title('第一次信号分解的低频分量频域图')subplot(2,2,2)stem(abs(ff
6、t(dec1_high)));title('第一次信号分解的高频分量频域图');subplot(2,2,3)stem(abs(fft(dec2_low)));title('第二次信号分解的低频分量频域图')subplot(2,2,4)stem(abs(fft(dec2_high)));title('第二次信号分解的高频分量频域图')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Mallat合成算法%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%dec2_low=dyaddown(dec2_low);%降采样,隔二取一dec2_high=dyaddown(dec2_high);dec2_low=dyadup(dec2_low);%上采样,即两个点中间插入一个值为零的点dec2_high=dyadup(dec2_high);dec2_low=dec2_low(1,[1:N]);%去掉多余项,即数据末尾的零dec2_high=dec2_high(1,[1:N