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.
Kshitij Singh answered .
2025-11-20
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:
Load the Signal: Load your signal matrix, where each row is a signal.
Design the Bandpass Filter: Use the designfilt function to create a bandpass filter.
Apply the Filter: Use the filtfilt function to apply the filter to each row.
% 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');
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.