📄 out.m
字号:
%采样频率
Fs=1000;
t=0:1/Fs:0.999;
f1=10;
x7=sin(2*pi*f1*t);
x8=0.5*sin(4*pi*f1*t);
x9=0.2*sin(8*pi*f1*t);
f2=300;
x10=0.5*sin(2*pi*f2*t);
x11=0.2*sin(4*pi*f2*t);
x13=rand(1,1000);
x=x7+x8+x9+x10+x11+x13;
plot(x);
%时域波形
figure(1);
plot(x);
xlabel('时间t/n');
ylabel('电压V/v');
%db10小波进行4层分解
%一维小波分解
[c,l]=wavedec(x,4,'db10');
%重构第1-4层细节信号
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);
%显示细节信号
figure(2)
subplot(4,1,1);
plot(d4,'LineWidth',2);
ylabel('d4');
subplot(4,1,2);
plot(d3,'LineWidth',2);
ylabel('d3');
subplot(4,1,3);
plot(d2,'LineWidth',2);
ylabel('d2');
subplot(4,1,4);
plot(d2,'LineWidth',2);
ylabel('d1');
xlabel('时间t/s');
%第一层细节信号的包络谱
y=hilbert(d1);
ydata=abs(y);
y=y-mean(y);
fs=6000;
nfft=1024;
p=abs(fft(ydata,nfft));
figure(3);
plot((0:nfft/2-1)/nfft*fs,p(1:nfft/2));
xlabel('频率f/Hz');
ylabel('功率谱P/W');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -