fs=?;
load data;
s=data(1:1024);
s=(s-mean(s))/std(s,1);
figure(1);
plot(s);
xlabel('采样点数');ylabel('幅值g');
title('原始信号');
[c,l]=wavedec(s,4,'db1');
d4=wrcoef('d',c,l,'db1',4);
d3=wrcoef('d',c,l,'db1',3);
d2=wrcoef('d',c,l,'db1',2);
d1=wrcoef('d',c,l,'db1',1);
figure(2);
subplot(411);plot(d4,'LineWidth',2);ylabel('d4');
subplot(412);plot(d3,'LineWidth',2);ylabel('d3');
subplot(413);plot(d2,'LineWidth',2);ylabel('d2');
subplot(414);plot(d1,'LineWidth',2);ylabel('d1');
xlabel('时间t');
ydata=abs(y);
y=y-mean(y);
nfft=1024;
p=abs(fft(ydata,nfft);
p=abs(fft(ydata,nfft));
figure(3);
plot((0:nfft/2-1)/nfft*fs,p(1:nfft/2));
xlabel('频率 f/Hz');ylabel('功率谱 P/W');
书上看到的,不知能不能用 |