Assuming you have designed a Butterworth LPF (Low-Pass Filter) with a specified cutoff frequency and order, you can use the freqz function in MATLAB to obtain the magnitude and phase response of the filter. Here is the code to do so:
main.m566 chars23 lines
This code defines a Butterworth filter with a cutoff frequency of 1000 Hz and a 5th order, using the butter function. It then computes the frequency response of the filter using the freqz function, which returns the complex frequency response h and the corresponding frequency vector w. The magnitude response is plotted on the top subplot, while the phase response is plotted on the bottom subplot.
Note that fs is the sampling frequency of the signal in Hz. If you don't know the sampling frequency, you can set it equal to 1 and the frequency axis will be normalized to the range [0, 0.5].
gistlibby LogSnag