How to do filtering using convolution and impulse response ?

2 次查看(过去 30 天)
I want to replicate a filters output by using convolution of the original signal with the impulse response generated by the same filter.Attached is the original data, now when I load the data and run the below filter script we should get a variable called filtered. If i replace the original data with just zero's in all the rows and columns and insert 1's for example in 12000th column, I am hoping that I am creating an impulse. Now if I give this impulse to the filter I should get impulse response. Well my question is when i use convolution as below
Output = conv2(Original,ir,'same');
The Output is not same as the filtered original signal. Can you please tell where am I doing wrong ? How to get the correct result ? Below is the script for filtering. Thank you in advance for helping me out.
clc
Fs = 128; % sample rate in Hz
N = 24031; % number of signal samples
rng default;
for channel = 1:14
sig=Original(channel, :);
xsig = sig';
tv = (0:N-1)/Fs; % time vector
Fnorm = 5/(Fs/2); % Normalized frequency
% df = designfilt('bandpassiir','FilterOrder',4, ...
% 'PassbandRipple',0.500000,'CutoffFrequency1',1.000000,'CutoffFrequency2',20.000000, ...
% 'SampleRate',Fs);
df = designfilt('bandpassiir', 'FilterOrder', 4, 'PassbandFrequency1', ...
1, 'PassbandFrequency2', 20, 'PassbandRipple', ...
0.500000, 'SampleRate', Fs);
grpdelay(df,2048,Fs); % plot group delay
%BPF = fvtool(df);
D = mean(grpdelay(df)); % filter delay in samples
ysig = filter(df,[xsig; zeros(round(D),1)]); % Append D zeros to the input data
ysig = ysig(D+1:end);
filtered(channel, :) = ysig'
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Filter Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by