Hi,
This is my first post on this forum
You can create a notch filter based on an IIR-Filter type.
The transfer function is:
H(z) = (1 - 2 * cos(w) * z^(-1) + z^(-2)) / (1 - 2 * p * cos(w) * z^(-1) + p^2 * z^(-2))
Whereas w is the normalized frequency that you want to remove (w = 2 * pi * f / fs).
p is a parameter in the range of [0,1]. It determines the radius of the pole location on the unit circle. The closer it is to 1, the narrower the notch bandwidth.
For your problem, you can now put two single notch filters in series.
Here an example code: I hope it is formatted correctly
%% Notch Filter Test
clear;clc;
fs = 1000; % Sampling frequency [Hz]
f1 = 100; % Notch filter frequency 1 [Hz]
f2 = 200; % Notch filter frequency 2 [Hz]
%% Design Notch filter for first frequency
%H(z) = (1 - 2 * cos(w1) * z^(-1) + z^(-2)) / (1 - 2 * p * cos(w1) * z^(-1) + p^2 * z^(-2))
p = 0.99; % The closer to one, the narrower the notch bandwidth
w1 = 2*pi*f1 / fs; % Convert f1 to normalized frequency [+-2*pi]
num1 = [1 , -2 * cos(w1), 1]; %IIR-Filter coefficients for numerator 1
denum1 = [1. -2 * p * cos(w1), p^2]; %IIR-Filter coefficients for denumerator 1
%% Design Notch filter for second frequency
w2 = 2*pi*f2 / fs; % Convert f2 to normalized frequency [+-2*pi]
num2 = [1 , -2 * cos(w2), 1]; %IIR-Filter coefficients for numerator 2
denum2 = [1. -2 * p * cos(w2), p^2]; %IIR-Filter coefficients for denumerator 2
%% Connect filter parameters in series
num = conv(num1,num2); %IIR-Filter coefficients numerator
denum = conv(denum1,denum2); %IIR-Filter coefficients denumerator
%% Create Filter object and plot
iir = dsp.IIRFilter('Numerator',num,'Denominator',denum);
freqz(iir)
Note: The vectors num and denum are the IIR-Filter coefficients. You can also plot the filter with freqz(num, denum)
With the iir-object, you can directly apply the filter to some measurement data.
The frequency response of this example is attatched.
I hope this example code helps you