原帖由 gaojian 于 2007-5-29 22:02 发表
如题!感激不尽!
典型的例子在很多相关的小波分析书中都有介绍:
我这有个小程序也是从书中得到的,可以供参考 %含噪的三角波与正弦波的组合
%生成正弦信号
clc;
clear;
close all;
N=1000;
t=0:0.001:0.6;
x=sin(2*pi*50*t)+sin(2*pi*120*t);
y=x+2*randn(size(t));
figure;
subplot(211)
plot(t,y,'LineWidth',2);
subplot(212)
plot(1000*t(1:50),y(1:50));
%xlabel('sample number n');
%ylabel('amplitude A');
%wavelet 1D decompose
[c,l]=wavedec(y,7,'db10');
% reconstruct 1-7 layer approach coefficient.
a7=wrcoef('a',c,l,'db10',7);
a6=wrcoef('a',c,l,'db10',6);
a5=wrcoef('a',c,l,'db10',5);
a4=wrcoef('a',c,l,'db10',4);
a3=wrcoef('a',c,l,'db10',3);
a2=wrcoef('a',c,l,'db10',2);
a1=wrcoef('a',c,l,'db10',1);
% show approach coefficient
figure
subplot(7,1,1);
plot(a7,'LineWidth',2);
ylabel('a7');
subplot(7,1,2);
plot(a6,'LineWidth',2);
ylabel('a6');
subplot(7,1,3);
plot(a5,'LineWidth',2);
ylabel('a5');
subplot(7,1,4);
plot(a4,'LineWidth',2);
ylabel('a4');
subplot(7,1,5);
plot(a3,'LineWidth',2);
ylabel('a3');
subplot(7,1,6);
plot(a2,'LineWidth',2);
ylabel('a2');
subplot(7,1,7);
plot(a1,'LineWidth',2);
ylabel('a1');
xlabel('sample sequence n');
% reconstruction 1-7 layer details coefficient
d7=wrcoef('d',c,l,'db10',7);
d6=wrcoef('d',c,l,'db10',6);
d5=wrcoef('d',c,l,'db10',5);
d4=wrcoef('d',c,l,'db10',4);
d3=wrcoef('d',c,l,'db10',3);
d2=wrcoef('d',c,l,'db10',2);
d1=wrcoef('d',c,l,'db10',1);
% show detail coefficient
figure
subplot(7,1,1);
plot(d7,'LineWidth',2);
ylabel('d7');
subplot(7,1,2);
plot(d7,'LineWidth',2);
ylabel('d6');
subplot(7,1,3);
plot(d5,'LineWidth',2);
ylabel('db5');
subplot(7,1,4);
plot(d5,'LineWidth',2);
ylabel('d4');
subplot(7,1,5);
plot(d3,'LineWidth',2);
ylabel('d3');
subplot(7,1,6);
plot(d2,'LineWidth',2);
ylabel('d2');
subplot(7,1,7);
plot(d1,'LineWidth',2);
ylabel('d1');
xlabel('sample squence n');
%%%%%%%%%%%%%%%hilbert
fs=1000;
Y2=fft(a1,512);
Pyy2=Y2.*conj(Y2)/512;
f2=1000*(0:256)/512;
y=hilbert(a1);
ydata=abs(y);
y=y-mean(y);
nfft=1000;
p=abs(fft(ydata,nfft));
y1=hilbert(d1);
ydata1=abs(y1);
y1=y1-mean(y1);
nfft=1000;
p1=abs(fft(ydata1,nfft));
figure
subplot(311)
plot((0:nfft/2-1)/nfft*fs,p(1:nfft/2));
subplot(312)
plot((0:nfft/2-1)/nfft*fs,p1(1:nfft/2));
subplot(313)
plot(f2,Pyy2(1:257));
[ 本帖最后由 hector1982 于 2007-5-30 09:36 编辑 ] |