How to apply bandpass filter

K
Katherine · Jan 15, 2021 · 2K views
Question
The  signal file is of 20Hz sampling rate. Each row is a signal, i needed to to apply bandpass filter to each row and convert it in the frequency range 0.34 - 1 Hz.
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Aug 24, 2026

To apply a bandpass filter to each row of a signal matrix and convert it to the frequency range 0.34 - 1 Hz in MATLAB, you can use the designfilt function to create the filter and then apply it to each row. Here's a step-by-step guide:

  1. Load the Signal: Load your signal matrix, where each row is a signal.

  2. Design the Bandpass Filter: Use the designfilt function to create a bandpass filter.

  3. Apply the Filter: Use the filtfilt function to apply the filter to each row.

Example:

matlab
% Load your signal matrix
% Assuming 'signalMatrix' is your matrix where each row is a signal
% Example: signalMatrix = rand(100, 1000); % 100 rows (signals) and 1000 columns (samples)

% Sampling frequency (Hz)
Fs = 20;

% Design a bandpass filter with a passband of 0.34 to 1 Hz
bpFilt = designfilt('bandpassiir', 'FilterOrder', 4, ...
                    'HalfPowerFrequency1', 0.34, ...
                    'HalfPowerFrequency2', 1, ...
                    'SampleRate', Fs);

% Initialize the filtered signal matrix
filteredSignalMatrix = zeros(size(signalMatrix));

% Apply the filter to each row
for k = 1:size(signalMatrix, 1)
    filteredSignalMatrix(k, :) = filtfilt(bpFilt, signalMatrix(k, :));
end

% Plot the original and filtered signals (for a selected row)
selectedRow = 1; % Choose a row to plot
figure;
subplot(2, 1, 1);
plot(signalMatrix(selectedRow, :));
title('Original Signal');
xlabel('Time (samples)');
ylabel('Amplitude');

subplot(2, 1, 2);
plot(filteredSignalMatrix(selectedRow, :));
title('Filtered Signal (Bandpass 0.34 - 1 Hz)');
xlabel('Time (samples)');
ylabel('Amplitude');

Explanation:

  • Load the Signal: Replace signalMatrix with your actual signal matrix.

  • Design the Bandpass Filter: The designfilt function creates a bandpass filter with the specified frequency range and sampling rate.

  • Apply the Filter: The filtfilt function applies the filter to each row of the signal matrix, ensuring zero-phase distortion.

  • Plotting: The original and filtered signals for a selected row are plotted for comparison.

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!