Creating impulse through a loop

7 ビュー (過去 30 日間)
S
S 2024 年 1 月 24 日
コメント済み: Hassaan 2024 年 1 月 26 日
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!

採用された回答

Hassaan
Hassaan 2024 年 1 月 24 日
% 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 件のコメント
S
S 2024 年 1 月 24 日
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 2024 年 1 月 26 日
Yes. You can review the code comments.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital and Analog Filters についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by