# MATLAB代做-信号包络分析

### 时间：2018-12-22 12:43:42 点击：

核心提示：MATLAB代做-信号包络分析...
clear all
x=x*1000/(2*20*10);
NN=length(x);

%作出时域波形
t=0.0001;
T=t*(0:12287);
N1=2048;
figure(1);
plot(T(1:N1),x(1:N1))
xlabel('时间t');
ylabel('加速度m/ss');
title('振动-时间波形');

%作出直接功率谱
fs=10000;
N2=20480;
window=hanning(N2);
xwin=x(1:N2).*window;%数据加窗
Pxx=abs(fft(xwin)).^2/(length(xwin));
m1=(0:N2/2-1)/N2*fs;
p1=Pxx(1:N2/2);
figure(2);
plot(m1,p1),grid
xlabel('f/Hz');
ylabel('P');
title('直接功率谱');

%低通滤波
wp=2300;rp=0.1;
ws=2500;rs=30;
fs=10000;
[n,Wn]=buttord(wp/(fs/2),ws/(fs/2),rp,rs)
[b,a]=butter(n,Wn);
x2000=filter(b,a,x);
%freqz(b,a,512,fs),pause
%降采样率
x2000x=x2000(1:2:NN);

%带通滤波
wp1=200;wp2=2300;wp=[wp1 wp2];rp=1;
ws1=100;ws2=2450;ws=[ws1 ws2];rs=30;
fs=5000;
[n,Wn]=buttord(wp/(fs/2),ws/(fs/2),rp,rs)
[b,a]=butter(n,Wn);
x2000x2=filter(b,a,x2000x);
%freqz(b,a,512,fs),pause
%做出时域波形
t=0.0002;
T=t*(0:6143);
N1=1024;
figure(3);
plot(T(1:N1),x2000x2(1:N1))
xlabel('时间t');
ylabel('电压V/v');
title('振动-时间波形');

NNN=length(x2000x2);
%分析出样本的峭度
K1=kurtosis(x2000x2)
y=mean(x2000x2)
%均方根
ys1105RMS=sqrt(sum(x2000x2.^2)/NNN)%因为进行了零均值处理，所以改变了
%每1024点取一个峰值
kk=NNN/1024
xx=0;
peak=0;
for j=1:kk
for i=1:1024
xx(i)=x2000x2((j-1)*1024+i);
end
peak(j)=max(abs(xx));
end
%峰值指标
ys1105peak=sum(peak)/kk
%峰值因子
ys1105crest=ys1105peak/ys1105RMS

%作出平均5次的功率谱
P=zeros(4096,1);
for i=1:5
fs=5000;
N2=4096;
window=hanning(N2);
xwin=x2000x2((i-1)*N2+1:(i-1)*N2+N2).*window;%数据加窗
Pxx2=abs(fft(xwin)).^2/(length(xwin));
P=P+Pxx2;
end
P=P/5;
m2=(0:N2/2-1)/N2*fs;
p2=P(1:N2/2);
figure(4);
plot(m2,p2),grid,,axis([0,2500,0,30])
xlabel('f/Hz');
ylabel('P');
title('5次平均功率谱');

%800-2000
%带通滤波
wp1=300;wp2=700;wp=[wp1 wp2];rp=1;
ws1=150;ws2=850;ws=[ws1 ws2];rs=30;
fs=5000;
[n,Wn]=buttord(wp/(fs/2),ws/(fs/2),rp,rs)
[b,a]=butter(n,Wn);
x1500x2=filter(b,a,x2000x2);

%对该频段包络解调
x1500h=hilbert(x1500x2);
x1500h=abs(x1500h);

%做包络的时域波形
t=0.0002;
T=t*(0:6143);
N1=1024;
figure(5);
plot(T(1:N1),x1500h(1:N1))
xlabel('时间t');
ylabel('电压V/v');
title('包络-时间波形');

%低通滤波
wp=300;rp=0.1;
ws=450;rs=30;
fs=5000;
[n,Wn]=buttord(wp/(fs/2),ws/(fs/2),rp,rs)
[b,a]=butter(n,Wn);
x1500h=filter(b,a,x1500h);

%包络谱细化
x1500hx=x1500h(1:8:NN/2);
N4=length(x1500hx)
xwin=x1500hx;
Pxx=abs(fft(xwin)).^2/(length(xwin));
m=(0:N4/2-1)/N4*(fs/8);
p=Pxx(1:N4/2);
figure(6);
plot(m,p),grid,axis([0,300,0,100])
xlabel('f/Hz');
ylabel('P');
title('包络信号细化功率谱');
gtext('33.94'),gtext('68.12'),gtext('102.05')

QQ ：1224848052

• 百度搜索
• 查阅资料过程中
• 论坛发现
• 百度贴吧发现
• 朋友介绍
• 没有相关文章
• 大名：
• 内容：