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.
2 views (last 30 days)
Show older comments
Trevon Alvarado
on 21 Apr 2020
Commented: Trevon Alvarado
on 21 Apr 2020
%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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/286168/image.png)
0 Comments
Accepted Answer
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)
See Also
Categories
Find more on Digital Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!