zoukankan      html  css  js  c++  java
  • 一维小波分解与去噪重构

    对于一些一维数据,先对该数据进行一维分解,得到两个参数C,L. 如具体代码 : 
                                [c,l] = wavedec(x,5,'db3');%5表示分解层数。x为原始数据,db3为小波信号的小波阶数。
    再进行数据重构,通过得到的C,L重构生成相应的系数(逼近系数和细节系数)
    逼近系数:
    a1 = wrcoef('a',c,l,'db3',1);%其中的a表示为逼近
    细节系数
    d1 = wrcoef('d',c,l,'db3',1);%其中的d表示为细节
    �3表示选取相应的小波信号dbN(N=1,2,3,...,10)及小波阶数。


    clc
    clear all
    close all
    % 当前延拓模式是补零
    oldmode = dwtmode('zpd');
    ts = 0.001;
    fs = 1/ts;
    t=0:ts:1;
    N = length(t);
    x = sin(2*pi*10*t) + sin(2*pi*50*t) + sin(2*pi*100*t) + 0.1*randn(1, length(t));
    figure
    plot(t,x);
    xlabel('时间 t/s');
    ylabel('幅值 A');
    % 一维小波分解
    [c,l] = wavedec(x,5,'db3');
    % 重构第1~5层逼近系数
    a5 = wrcoef('a',c,l,'db3',5);
    a4 = wrcoef('a',c,l,'db3',4);
    a3 = wrcoef('a',c,l,'db3',3);
    a2 = wrcoef('a',c,l,'db3',2);
    a1 = wrcoef('a',c,l,'db3',1);
    % 显示逼近系数
    figure
    subplot(5,1,1);plot(a5);ylabel('a5');
    subplot(5,1,2);plot(a4);ylabel('a4');
    subplot(5,1,3);plot(a3);ylabel('a3');
    subplot(5,1,4);plot(a2);ylabel('a2');
    subplot(5,1,5);plot(a1);ylabel('a1');
    xlabel('时间 t/s');
    % 重构第1~5层细节系数
    d5 = wrcoef('d',c,l,'db3',5);
    d4 = wrcoef('d',c,l,'db3',4);
    d3 = wrcoef('d',c,l,'db3',3);
    d2 = wrcoef('d',c,l,'db3',2);
    d1 = wrcoef('d',c,l,'db3',1);
    % 显示细节系数
    figure
    subplot(5,1,1);plot(d5);ylabel('d5');
    subplot(5,1,2);plot(d4);ylabel('d4');
    subplot(5,1,3);plot(d3);ylabel('d3');
    subplot(5,1,4);plot(d2);ylabel('d2');
    subplot(5,1,5);plot(d1);ylabel('d1');
    xlabel('时间 t/s');
    % 第1层细节信号的包络谱
    yh = hilbert(d3);
    aabs = abs(yh);                 % 包络的绝对值
    aabs = aabs - mean(aabs);
    aangle = unwrap(angle(yh));     % 包络的相位
    af = diff(aangle)/2/pi;         % 包络的瞬时频率,差分代替微分计算
    % NFFT = 2^nextpow2(N);
    NFFT = 2^nextpow2(1024*4);      % 改善栅栏效应
    f = fs*linspace(0,1,NFFT);
    YH = fft(yh, NFFT)/N;           % Hilbert变换复信号的频谱
    A = fft(aabs, NFFT)/N;          % 包络的频谱
    figure
    plot(f,abs(YH))
    title('原始复信号的Hilbert谱')
    xlabel('频率f (Hz)')
    ylabel('|YH(f)|')
    figure
    subplot(221)
    plot(t, aabs')
    title('包络的绝对值')
    legend('包络分析结果', '真实包络')
    subplot(222)
    plot(t, aangle)
    title('调制信号的相位')
    subplot(223)
    plot(t(1:end-1), af*fs)
    title('调制信号的瞬时频率')
    subplot(224)
    plot(f,abs(A))
    title('包络的频谱')
    xlabel('频率f (Hz)')
    ylabel('|A(f)|')
    % 恢复延拓模式
    dwtmode(oldmode);

  • 相关阅读:
    C# 遍历Hashtable
    asp.net 处理超链接中文参数编码问题
    electronvue开发问题总结
    vue全局使用样式文件vueclipluginstyleresourcesloader
    win10使用VMware安装macOS11.1镜像系统教程
    LVM从CentOS7默认安装的/home中转移空间到根目录/(转载)
    Nginx引用多配置文件
    ssh_exchange_identification: read: Connection reset by peer
    linux修改时区
    修改键盘Tab键为四个空格
  • 原文地址:https://www.cnblogs.com/xuxinstyle/p/9128889.html
Copyright © 2011-2022 走看看