Creating impulse through a loop

7 Ansichten (letzte 30 Tage)
S
S am 24 Jan. 2024
Kommentiert: Hassaan am 26 Jan. 2024
So I am trying to run an impulse through a set of bandpass filters ins series that I have made to get its impulse response.
Here is the loop with the series bp filters:
fs = 16e3;
numFilts = 32;
BW = 100; %Filter Bandwidth
filter_number = 10;
%range = [50 8000];
CenterFreqs = linspace(50, 8000, numFilts);
CF1 = CenterFreqs - BW/2;
CF2 = CenterFreqs + BW/2;
for ii = 1:filter_number
bpfilt{ii} = designfilt( ...
'bandpassfir', ...
'FilterOrder',20, ...
'CutoffFrequency1',CF1(ii+1), ...
'CutoffFrequency2',CF2(ii+1), ...
'SampleRate',fs);
end
So now I am trying to define an impulse like this:
impulse_input = 0*t;
impulse_input(1) = 1;
but am not sure what length to make my t, or how to apply the filter I made in the loop to it. Thank you for your time!

Akzeptierte Antwort

Hassaan
Hassaan am 24 Jan. 2024
% Filter specifications
fs = 16e3; % Sampling frequency
numFilts = 32; % Total number of filters (not all used)
BW = 100; % Filter bandwidth
filter_number = 10; % Number of filters to use
CenterFreqs = linspace(50, 8000, numFilts); % Center frequencies
CF1 = CenterFreqs - BW/2; % Lower cutoff frequencies
CF2 = CenterFreqs + BW/2; % Upper cutoff frequencies
% Design bandpass filters
bpfilt = cell(1, filter_number);
for ii = 1:filter_number
bpfilt{ii} = designfilt('bandpassfir', 'FilterOrder', 20, ...
'CutoffFrequency1', CF1(ii+1), ...
'CutoffFrequency2', CF2(ii+1), ...
'SampleRate', fs);
end
% Define the impulse signal
t_length = 1000; % Length of the impulse signal
impulse_input = zeros(1, t_length); % Initialize the impulse signal
impulse_input(1) = 1; % Set the first sample to 1 for impulse
% Apply the filters in series
filtered_signal = impulse_input;
for ii = 1:filter_number
filtered_signal = filter(bpfilt{ii}, filtered_signal);
end
% Plot the final output
plot(filtered_signal);
title('Combined Impulse Response of Bandpass Filters');
xlabel('Samples');
ylabel('Amplitude');
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.
  2 Kommentare
S
S am 24 Jan. 2024
This looks great! Is this still using all the filters in series, using the output of one as the input to the next?
Hassaan
Hassaan am 26 Jan. 2024
Yes. You can review the code comments.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Digital and Analog Filters finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by