Filter löschen
Filter löschen

How do you add a sampling interval to a low pass filter?

2 Ansichten (letzte 30 Tage)
Brianna Miranda
Brianna Miranda am 13 Dez. 2021
Beantwortet: Shreshth am 15 Feb. 2024
How do I add a sampling interval of .1s to a low pass filter if I am using the fdesign.lowpass feature? This is what I have so far.
Fc = .99; % cutoff frequency (*pi radians)
N = 63; % filter order
Hn = fdesign.lowpass('N,Fc',N,Fc);
Hd1 = design(Hn,'window','window',@hamming,'systemobject',true);
Hd2 = design(Hn,'window','window',{@chebwin,50},'systemobject',true);
hfvt = fvtool(Hd1,Hd2,'Color','White');
legend(hfvt,'Hamming window design','Dolph-Chebyshev window design')
  1 Kommentar
Mathieu NOE
Mathieu NOE am 14 Dez. 2021
you simply have to design a pure delay filter (with is a FIR fiter : F(z^-1) = z^(-nd))
nd depends of your sampling rate and time delay (here 0.1s)
for example is Fs = 1000 Hz (dt = 1/1000 s) you would need nd = 100 samples of delay

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Shreshth am 15 Feb. 2024
Hello Brianna,
I can see from your question that you are trying to implement a low pass filter using the ‘fdesign.lowpass’ function and also incorporating a sampling interval of 0.1 seconds into the filter.
For this purpose you need to specify the sampling frequency Fs as the inverse of the sampling interval. In your case, since the sampling interval is 0.1 seconds, the sampling frequency Fs would be 10 Hz.
You can specify the sampling frequency directly in the ‘fdesign.lowpass’function by adding it as a parameter. Here is how you can modify your code to include the sampling frequency:
Fc = 0.99; % cutoff frequency (*pi radians)
Fs = 10; % sampling frequency (Hz)
N = 63; % filter order
% Define the lowpass filter design object with sampling frequency Fs
Hn = fdesign.lowpass('N,Fc', N, Fc, Fs);
% Design the filter using a Hamming window
Hd1 = design(Hn, 'window', 'window', @hamming, 'systemobject', true);
% Design the filter using a Dolph-Chebyshev window with 50 dB sidelobe attenuation
Hd2 = design(Hn, 'window', 'window', {@chebwin, 50}, 'systemobject', true);
% Visualize the frequency response of both filters
hfvt = fvtool(Hd1, Hd2, 'Color', 'White');
legend(hfvt, 'Hamming window design', 'Dolph-Chebyshev window design');
In the above code, Fs is set to 10 Hz, which corresponds to a sampling interval of 0.1 seconds. The ‘fdesign.lowpass’function now includes the sampling frequency in its parameters, which allows the design process to take into account the correct time domain discretization when creating the filter.
To understand the use of of ‘fdesing.lowpass’ filter you can also refer to the below MathWorks documentation:
Hope it helps.
Shubham Shreshth

Community Treasure Hunt

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

Start Hunting!

Translated by