Hello I'm having a problem where I want to add multiple band pass filters onto one graph but, I have an error that I can figure out how to solve it.

3 次查看(过去 30 天)
%Specify synthetic input signal parameters - sum of 2 sinusoids
f0=1600;
f1=7600;
fs=20000;
t=0:1/fs:0.5-(1/fs);
x1=1*sin(2*pi*f0*t);
x2=1*sin(2*pi*f1*t);
xin=x1+x2;
signal_power=var(xin)
%add in some white gaussian noise
xnse=wgn(1,10000,0.1,'linear');
noise_power=var(xnse)
SNR=10*log10(signal_power/noise_power)
in_file = xin + xnse;
%specify taylor window to be used for spectral estimation
w0=taylorwin(512,4,-80);
%Specify use of the Taylor window
t_window=taylorwin(51,20,-100);What I have:
N=input("Please Enter The Amount Of Filters Needed: ")
for k = 1:N
disp('Band Pass Filter \n')
%Filter Band pass filter cutoffs in Hz
Lc1(k)=input('Input The Lcl: ');
Uc1(k)=input('Input The Ucl: ');
g1(k)=input('Input The Gain: ');
Lc1_norm(k)=2*Lc1(k)/fs;
Uc1_norm(k)=2*Uc1(k)/fs;
b=fir1(50,[Lc1_norm(k) Uc1_norm(k)],t_window);
bfilterbank= g1.*b ;
out_file = filter(bfilterbank,1,in_file);
figure();
freqz(b,1);
title('FIR Filter #1 Magn. & Phase Function Plots');
hold on
end
%ERROR

采纳的回答

Mehmed Saad
Mehmed Saad 2020-4-21
编辑:Mehmed Saad 2020-4-21
Change the line g1.*b to
bfilterbank= g1(k).*b ;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by