當前位置:編程學習大全網 - 編程語言 - 小波分析在matlab中實現的具體步驟

小波分析在matlab中實現的具體步驟

%含噪聲的三角波與正弦波的組合

%利用db5小波對信號進行7層分解

%生產正弦信號

clc;close all;clear all;

N=1000;

t=1:N;

sig1=sin(0.3*t);

%生成三角形波形

sig2(1:500)=((1:500)-1)/500;

sig2(501:N)=(1000-(501:1000))/500;

figure(1);

subplot(211);

plot(t,sig1,'linewidth',2);

xlabel('樣本序號 N');

ylabel('幅值A');

subplot(212);

plot(t,sig2,'linewidth',2);

xlabel('樣本序號 N');

ylabel('幅值A');

%疊加信號

x=sig1+sig2+randn(1,N);

figure(2);

plot(t,x,'linewidth',2);

xlabel('樣本序號 N');

ylabel('幅值A');%壹維小波分解

[c,l]=wavedec(x,7,'db5');%重構第1-7層逼近系數

a7=wrcoef('a',c,l,'db5',7);

a6=wrcoef('a',c,l,'db5',6);

a5=wrcoef('a',c,l,'db5',5);

a4=wrcoef('a',c,l,'db5',4);

a3=wrcoef('a',c,l,'db5',3);

a2=wrcoef('a',c,l,'db5',2);

a1=wrcoef('a',c,l,'db5',1);%顯示逼近系數

figure(3)

subplot(711)

plot(a7,'linewidth',2);

ylabel('a7');

subplot(712)

plot(a6,'linewidth',2);

ylabel('a6');

subplot(713)

plot(a5,'linewidth',2);

ylabel('a5');

subplot(714)

plot(a4,'linewidth',2);

ylabel('a4');

subplot(715)

plot(a3,'linewidth',2);

ylabel('a3');

subplot(716)

plot(a2,'linewidth',2);

ylabel('a2');

subplot(717)

plot(a1,'linewidth',2);

ylabel('a1');

xlabel('樣本序號 N');%重構第1-7層細節系數

d7=wrcoef('d',c,l,'db5',7);

d6=wrcoef('d',c,l,'db5',6);

d5=wrcoef('d',c,l,'db5',5);

d4=wrcoef('d',c,l,'db5',4);

d3=wrcoef('d',c,l,'db5',3);

d2=wrcoef('d',c,l,'db5',2);

d1=wrcoef('d',c,l,'db5',1);

%顯示細節系數

figure(4)

subplot(711)

plot(d7,'linewidth',2);

ylabel('d7');

subplot(712)

plot(d6,'linewidth',2);

ylabel('d6');

subplot(713)

plot(d5,'linewidth',2);

ylabel('d5');

subplot(714)

plot(d4,'linewidth',2);

ylabel('d4');

subplot(715)

plot(d3,'linewidth',2);

ylabel('d3');

subplot(716)

plot(d2,'linewidth',2);

ylabel('d2');

subplot(717)

plot(d1,'linewidth',2);

ylabel('d1');

xlabel('樣本序號 N');

  • 上一篇:求壹份機械專業的簡歷,交作業用的
  • 下一篇:如何利用混合進制將文本信息進行隱藏
  • copyright 2024編程學習大全網