matlab冲击噪声,如何用MATLAB生成噪声和冲击混合信号
剛接觸MATLAB,想請(qǐng)教老師們,如何編寫一個(gè)噪聲和沖擊的模擬信號(hào),還有關(guān)于共振解調(diào)的程序想請(qǐng)專業(yè)人士幫看看哪里有問題
fs = 10^6;%采樣頻率
N=4096;%采樣長度
t=(0:N-1)/fs;%產(chǎn)生時(shí)間序列
x=load('jiaozai.m');
subplot(211)
plot(t,x)
title('時(shí)域波形');
axis([0 1.2 -8 8]*10^-3);
ylabel('振幅/m/s^2');
xlabel('時(shí)間/s');
grid on;
%初始信號(hào)的fft變換
f =fs*(1:N/2)/N;
S1=abs(fft(x))*2/N;
subplot(212)
plot(f,S1(1:N/2));
title('頻域波形');
ylabel('振幅/m/s^2');
xlabel('頻率/Hz');
grid on;
%對(duì)信號(hào)的預(yù)處理
m=1;
t1=reshape(t,4096,1);
a=polyfit(t1,x,m);
y1=x-polyval(a,t1);
figure(2)
plot(t1,y1,'r');
hold on
plot(t1,x);
axis([0 1.2 -8 8]*10^-3);
title('預(yù)處理:去除趨勢(shì)項(xiàng)');
xlabel('時(shí)間/s');
ylabel('振幅/m')
grid on;
%預(yù)處理:小波降噪
[c,l]=wavedec(y1,3,'sym8');
[thr,sorh,keepapp]=ddencmp('den','wv',y1);
y2=wdencmp('gbl',y1,'sym8',3,thr,sorh,keepapp);
figure(3)
plot(t,y2,'r');
hold on
plot(t,y1);
axis([0 1.2 -8 8]*10^-3);
title('預(yù)處理:小波降噪');
xlabel('時(shí)間/s');ylabel('振幅/m')
grid on;
%降噪后頻域圖
f =fs*(1:N/2)/N;
S2=abs(fft(y1))*2/N;
figure(4)
plot(f,S2(1:N/2),'r');
hold on
plot(f,S1(1:N/2));
title('頻域波形');
ylabel('振幅/m/s^2');
xlabel('頻率/Hz');
grid on;
%預(yù)處理:帶通濾波
Wn=[0.3,0.4];
[b,a]= butter(4,Wn,'s');
y3= filter(b,a,y2);
figure(5);
plot(t,y3);
axis([0 1.6*10^-3 -8*10^-7 8*10^-7]);
title('預(yù)處理:帶通濾波');
grid on;
%帶通后頻域圖
y4=fft(y3,N);
mag2=abs(y4);
f=(0:N-1)*fs/N;
figure(6)
plot(f,mag2,'r');
hold on
plot(f,S1(1:N));
axis([0 5*10^5 0 3*10^-4]);
title('頻域波形');
ylabel('振幅/m/s^2');
xlabel('頻率/Hz');
grid on;
%帶通濾波后的包絡(luò)時(shí)域圖
X = hilbert(y3);%計(jì)算信號(hào)的hilbert變換
Amp= abs(X); %計(jì)算信號(hào)的瞬時(shí)功率
figure(7);
plot(t,Amp);%畫包絡(luò)時(shí)域圖
title('帶通濾波后的包絡(luò)時(shí)域波形');
axis([0 1.6*10^-3 0 9*10^-7]);
ylabel('振幅/m/s^2');
xlabel('時(shí)間/s');
grid on;
%帶通濾波后的包絡(luò)頻域圖
envelop_fft = abs(fft(Amp))*2/N;
figure(8);
plot(f,10*envelop_fft(1:N));%畫包絡(luò)頻譜圖
axis([0 5*10^5 0 0.3*10^-6]);
title('包絡(luò)頻域波形');
ylabel('振幅/m/s^2');
xlabel('頻率/Hz');
grid on
總結(jié)
以上是生活随笔為你收集整理的matlab冲击噪声,如何用MATLAB生成噪声和冲击混合信号的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql的内存数据库,MySQL内存数
- 下一篇: 打杖红十字救护员可以上战场吗