概述
Fs = 2000;
% parameters for stft
Nwin = 128;
Nfft = Nwin;
Noverlap = 0.5*Nwin;
wintype= 'ham';
T = 0.6; %s
% preparation
win = window_stft(wintype, Nwin);
%No of samples
N = Fs*T;
% s1 = wgn(N,6,0.6);
window = rectwin(N); %hann(N);
% white = randn(N,1);
white = wgn(N,1,0);
white = (white.*window)';
white = white';
% white = white/(max(abs(white(:))));
audiowrite('Full band Gaussin White Noise.wav',white,Fs);
% bandpass filter
Fs2 = Fs/2;
fp1 = 170;fp2 = 520;
fs1 = 150;fs2 = 550;
% Filter_length = 30;
df = (fp1 - fs1)*pi/Fs2;
Filter_length = ceil(6.6*pi/df);
f = [0 fs1 fp1 fp2 fs2 Fs2]/Fs2;
ideal_amp = [0 0 1 1 0 0];
b2 = fir2(Filter_length,f,ideal_amp);
[H,ff]=freqz(b2,1,2000,Fs);
white=filter(b2,1,white);
audiowrite('Band limited Gaussin White Noise.wav',white,Fs);
[S,f,t] = spectrogram(white, win, Noverlap, Nfft, Fs);
NOISE_frame = fft(white,Nfft)/(Nwin); % a frame of frequency-domain point noise
NOISE_shift = 2*fftshift(NOISE_frame);
% NOISE_shift=2*fftshift(abs(NOISE_frame));
% NOISE_input = (NOISE_shift(Nwin/2:1:Nwin));
NOISE_input = fliplr(NOISE_shift(1:Nwin/2 + 1).');
f_index=(0:Nwin-1)*Fs/Nwin-Fs/2;
figure;
subplot(221);
plot((1:N)'/Fs,white); xlabel('时间/s');title('全频带高斯白噪声时域信号')
subplot(222);
plot(ff,abs(H),'k');
grid; %axis([0 25 0 1.1]);
xlabel('频率/Hz'); ylabel('幅值')
title('巴特沃斯滤波器的幅值响应')
set(gcf,'color','w');
subplot(223);
contour(t,f(1:Nwin/2),20*log10(abs(S(1:Nwin/2,:))));
set(gca, 'YTickmode', 'manual', 'YTick', [0,50,100,200,400,500]);colorbar;
grid; ylabel('频率/Hz'); xlabel('时间/s');title('带限高斯白噪声STFT结果')
subplot(224)
plot(f_index,abs(NOISE_shift),'ko-')
set(gcf,'position',[174,232,1280,626]);
set(gcf,'DefaultTextInterpreter','latex')
grid on;title('带限高斯白噪声FFT结果')
figure
f_index_shift = [f_index(Nfft/2+1:Nfft),Fs/2]';
plot(f_index_shift,abs(NOISE_input),'ko-')
%set(gcf,'position',[174,232,1280,626]);
set(gcf,'DefaultTextInterpreter','latex')
grid on;title('带限高斯白噪声FFT结果')
最后
以上就是单纯中心为你收集整理的gauss bandpass filter matlab,采样频率对巴特沃兹滤波器设计的影响的全部内容,希望文章能够帮你解决gauss bandpass filter matlab,采样频率对巴特沃兹滤波器设计的影响所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复