To design a Butterworth low-pass filter with a filter order of 20 in MATLAB, use the butter
function.
main.m339 chars18 lines
Here, n
is the filter order, fc
is the cutoff frequency, and fs
is the sampling frequency in Hz. The Wn
variable is the normalized cutoff frequency, which is calculated as the ratio of the cutoff frequency to half the sampling frequency.
The butter
function returns the numerator and denominator coefficients of the digital Butterworth filter transfer function for the given filter order and cutoff frequency. The 'low'
option in the function call specifies that a low-pass filter should be designed.
Finally, the filter
function is used to apply the designed filter coefficients to the input signal xptq
, resulting in the filtered output signal y
.
gistlibby LogSnag