# How to define cutoff freqeuncy when using rectwin for lowpass filtering?

6 Ansichten (letzte 30 Tage)
Kalasagarreddi Kottakota am 7 Jul. 2023
Beantwortet: Sai Pallav am 13 Jul. 2023
Hi, when perfoming lowpass filtering, how to choose the cut-off freqeuncy argument? Is it fc/fs/2 or fc/fs? fc is cut off frequency in Hz.
fs %------sampling frequency
fc_normaized = fc/fs/2;--------?
N = 1/fc_normalized;
h = rectwin(N);
ll
fs %------sampling frequency
fc_normaized = fc/fs%-----------------?
N = 1/fc_normalized;
h = rectwin(N);
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Mathieu NOE am 10 Jul. 2023
Bearbeitet: Mathieu NOE am 10 Jul. 2023
usually we say that a cut off frequency is normalized vs the Nyquist frequency (which is fs/2)
so the right answer is : fc/(fs/2) = 2*fc/fs;

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Sai Pallav am 13 Jul. 2023
Hi,
As Mathieu mentioned in the comments cutoff frequency can be calculated using
cutoff = fc/(fs/2);
But rectwin is used for creating a window and it takes argument which specifies the length of the window. Refer rectwin documentation for more info.
Try a similar piece of code for creating a low-pass filter.
% Filter specifications
cutoff_frequency = 1000; % Desired cutoff frequency in Hz
filter_order = 50;
% Calculate window length
window_length = filter_order + 1;
% Generate rectangular window
window = rectwin(window_length);
% Normalize the window
window = window / sum(window);
% Generate ideal low pass filter coefficients
filter_coefficients = fir1(filter_order, cutoff_frequency/(fs/2), 'low');
% Apply the window to the filter coefficients
filtered_coefficients = filter_coefficients .* window;
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Bartlett finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by