function [ output_args ] = Untitled1( input_args )
N=1024;
t1=0+1/N:1/N:0.5;
t2=0.5+1/N:1/N:1;
s2=sin(2*pi*200*t2+pi/3).*exp(-15*(t2-0.5));
x1=9*sin(100*pi*t1)+5*sin(180*pi*t1)+sin(240*pi*t1);
x2=9*sin(100*pi*t2)+5*sin(180*pi*t2)+sin(240*pi*t2)+20*s2;
t=[t1,t2];
x=[x1,x2];
figure; %picture 1
subplot(3,1,1);plot(t1,x1);
subplot(3,1,2);plot(t2,x2);
subplot(3,1,3);plot(t,x);
wpt=wpdec(x,3,'db10','shannon');%'db30'
%one level show
figure;
s11=wprcoef(wpt,[1,0]);
s12=wprcoef(wpt,[1,1]);
subplot(2,1,1);plot(s11); ylabel('S11');
subplot(2,1,2);plot(s12); ylabel('S12');
%two level
figure;
s21=wprcoef(wpt,[2,0]);
s22=wprcoef(wpt,[2,1]);
s23=wprcoef(wpt,[2,2]);
s24=wprcoef(wpt,[2,3]);
subplot(4,1,1);plot(s21); ylabel('S21');
subplot(4,1,2);plot(s22); ylabel('S22');
subplot(4,1,3);plot(s23); ylabel('S23');
subplot(4,1,4);plot(s24); ylabel('S24');
%three level
s230=wprcoef(wpt,[3,0]);
s231=wprcoef(wpt,[3,1]);
s232=wprcoef(wpt,[3,2]);
s233=wprcoef(wpt,[3,3]);
s234=wprcoef(wpt,[3,4]);
s235=wprcoef(wpt,[3,5]);
s236=wprcoef(wpt,[3,6]);
s237=wprcoef(wpt,[3,7]);
s20=norm(s230);
s21=norm(s231);
s22=norm(s232);
s23=norm(s233);
s24=norm(s234);
s25=norm(s235);
s26=norm(s236);
s27=norm(s237);
st20=std(s230);
st21=std(s231);
st22=std(s232);
st23=std(s233);
st24=std(s234);
st25=std(s235);
st26=std(s236);
st27=std(s237);
disp('信号的特征向量');
snorm2=[s20,s21,s22,s23,s24,s25,s26,s27]
std2=[st20,st21,st22,st23,st24,st25,st26,st27]
figure; %picture 2
subplot(9,1,1);plot(s230);
ylabel('S230');
subplot(9,1,2);plot(s231);
ylabel('S231');
subplot(9,1,3);plot(s232);
ylabel('S232');
subplot(9,1,4);plot(s233);
ylabel('S233');
subplot(9,1,5);plot(s234);
ylabel('S234');
subplot(9,1,6);plot(s235);
ylabel('S235');
subplot(9,1,7);plot(s236);
ylabel('S236');
subplot(9,1,8);plot(s237);
ylabel('S237');% xlabel('t/ms');
figure
wpt=wpdec(x,1,'db10','shannon');
eng=wenergy(wpt);
subplot(3,1,1);bar(eng);title('Energy');
wpt=wpdec(x,2,'db10','shannon');
eng=wenergy(wpt);
subplot(3,1,2);bar(eng);
wpt=wpdec(x,3,'db10','shannon');
eng=wenergy(wpt);
subplot(3,1,3);bar(eng);
%fft
%{
figure
y230=fft(s230,1024);
py230=y230.*conj(y230)/1024;
y231=fft(s231,1024);
py231=y231.*conj(y231)/1024;
y232=fft(s232,1024);
py232=y232.*conj(y232)/1024;
y233=fft(s233,1024);
py233=y233.*conj(y233)/1024;
y234=fft(s234,1024);
py234=y234.*conj(y234)/1024;
y235=fft(s235,1024);
py235=y235.*conj(y235)/1024;
y236=fft(s236,1024);
py236=y236.*conj(y236)/1024;
y237=fft(s237,1024);
py237=y237.*conj(y237)/1024;
f=1000*(0:511)/1024;
y2=fft(x,1024);
py2=y2.*conj(y2)/1024;
plot(f,py2(1:512)); ylabel('P2'); title('信号的功率谱');grid on;
figure
subplot(4,2,1);
plot(f,py230(1:512));
ylabel('P230');
title('S230的功率谱')
subplot(4,2,2);
plot(f,py231(1:512));
ylabel('P231');
title('S231的功率谱')
subplot(4,2,3);
plot(f,py232(1:512));
ylabel('P232');
subplot(4,2,4);
plot(f,py233(1:512));
ylabel('P233');
subplot(4,2,5);
plot(f,py234(1:512));
ylabel('P234');
subplot(4,2,6);
plot(f,py235(1:512));
ylabel('P235');
subplot(4,2,7);
plot(f,py236(1:512));
ylabel('P236');
subplot(4,2,8);
plot(f,py237(1:512));
ylabel('P237');
%}
评论0