フィルターのクリア

notch filter to remove 50Hz fundamental frequency and its second (100 Hz) and third (150Hz) harmonics. with using filter(),

27 ビュー (過去 30 日間)
nrgsn
nrgsn 2019 年 12 月 11 日
編集済み: Walter Roberson 2022 年 8 月 25 日
My code is down below I get the error like this Not enough input arguments. Error in ecg (line 22 ) d = round(d0 * L / d0(15)); % Scale them to fit in length L.
How can I fix this please help me
lz
oad ecg.mat; % Load noisy ECG recording
%Bandpass filter
fs = 500; % Sampling rate
T = 1/500; % Sampling interval
b1 =[0.9765 -1.5800 0.9765]; %Notch filter with a notch frequency of 50 Hz
a1 =[1.0000 -1.5774 0.9504];
b2 =[0.9753 -0.6028 0.9753]; % Notch filter with a notch frequency 100 Hz
a2 =[1.0000 -0.6025 0.9504];
b3 =[0.9751 0.6027 0.9751]; % Notch filter with a notch frequency of 150 Hz
a3 =[1.0000 0.6025 0.9504];
y1 = filter(b1,a1,ecg); % First section filtering
y2 = filter(b2,a2,y1); % Second section filtering
y3 = filter(b3,a3,y2); % Third section filtering

回答 (2 件)

Daniel M
Daniel M 2019 年 12 月 11 日
編集済み: Daniel M 2019 年 12 月 11 日
'ecg' is the name of a function in the example:
MATLAB/Examples/R2019a/dsp/FindHeartRateUsingPeakFinderPanelWithECGInputSignalExample/ecg.m
If 'ecg.mat' is also the name of a file of yours, I suggest loading it in as follows:
data = load('ecg.mat');
ecg = data.ecg; % if the name of the variable actually IS ecg
Otherwise, I have not looked at the code you're using to create filters. Let me know if there are problems with that and I'll take a closer look.
  2 件のコメント
nrgsn
nrgsn 2019 年 12 月 11 日
It didn't work .I changed ecg to signalNoise(I used whos command to find it) then it worked without error but this time my plots are wrong.I am posting code with plot command could you tell me what is the problem?Is it filtering or something else?
clear
clc
load ecg.mat; % Load noisy ECG recording
x=signalNoise;
L=length(x);
fs = 500; % Sampling rate
T = 1/500; % Sampling interval
t =(0:L-1)*T; % Time vector
b1 =[0.9765 -1.5800 0.9765]; %Notch filter with a notch frequency of 50 Hz
a1 =[1.0000 -1.5774 0.9504];
b2 =[0.9753 -0.6028 0.9753]; % Notch filter with a notch frequency 100 Hz
a2 =[1.0000 -0.6025 0.9504];
b3 =[0.9751 0.6027 0.9751]; % Notch filter with a notch frequency of 150 Hz
a3 =[1.0000 0.6025 0.9504];
y1 = filter(b1,a1,x); % First section filtering
y2 = filter(b2,a2,y1); % Second section filtering
y3 = filter(b3,a3,y2); % Third section filtering
% BLT design
wd1 = 2*pi*0.25;
wd2 = 2*pi*40;
wa1 =(2/T)*tan(wd1*T/2);
wa2 =(2/T)*tan(wd2*T/2);
[B,A]=lp2bp([1.4314], [1 1.4652 1.5162],sqrt(wa1*wa2),wa2-wa1);
[b,a]=bilinear(B,A,fs);
b =[ 0.046361 0 -0.092722 0 0.046361];
a =[1 -3.352292 4.255671 -2.453965 0.550587];
y4 = filter(b,a,y3); %Bandpass filtering
subplot(3,1,1);plot(t,signalNoise);grid;ylabel('(a)');
subplot(3,1,2);plot(t,y3);grid;ylabel('(b)');
subplot(3,1,3);plot(t,y4);grid;ylabel('(c)');
xlabel('Time (sec.)');

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


Sabbir Ahmed
Sabbir Ahmed 2022 年 8 月 25 日
Hi, May I know how you got the notch filter's coefficient for different noise section?

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by