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.

1 view (last 30 days)
%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

Accepted Answer

Mehmed Saad
Mehmed Saad on 21 Apr 2020
Edited: Mehmed Saad on 21 Apr 2020
Change the line g1.*b to
bfilterbank= g1(k).*b ;

More Answers (0)

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!