Filtro Butterworth - função buttord e butter Matlab

3 min read 1 year ago
Published on Aug 15, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial provides a step-by-step guide on how to configure a Butterworth low-pass filter in MATLAB using the buttord and butter functions. Understanding how to implement this filter is essential for signal processing applications, where you need to eliminate high-frequency noise while preserving the integrity of your signal.

Step 1: Define Filter Specifications

Before creating a Butterworth filter, you need to establish your filter specifications, including the desired passband and stopband frequencies.

  • Choose the Passband Frequency (Wp): This is the frequency up to which the signal will pass without significant attenuation.
  • Choose the Stopband Frequency (Ws): This is the frequency beyond which the signal will be significantly attenuated.
  • Choose the Passband Ripple (Rp): This is the maximum allowable loss in the passband, usually expressed in decibels (dB).
  • Choose the Stopband Attenuation (Rs): This is the minimum attenuation required in the stopband, also expressed in dB.

Example

  • Wp = 0.3 (normalized frequency)
  • Ws = 0.5 (normalized frequency)
  • Rp = 1 (dB)
  • Rs = 40 (dB)

Step 2: Calculate the Filter Order and Cutoff Frequency

Use the buttord function to determine the minimum order of the filter and the cutoff frequency based on the specifications set in Step 1.

Code Example

[order, Wn] = buttord(Wp, Ws, Rp, Rs);
  • order will give you the required order of the filter.
  • Wn will provide the cutoff frequency normalized between 0 and 1.

Step 3: Design the Butterworth Filter

After determining the filter order and cutoff frequency, use the butter function to create the filter coefficients.

Code Example

[b, a] = butter(order, Wn);
  • b contains the numerator coefficients.
  • a contains the denominator coefficients.

Step 4: Apply the Filter to Your Signal

Once the filter is designed, use the filter function to apply it to your input signal.

Code Example

filtered_signal = filter(b, a, input_signal);
  • Replace input_signal with your actual signal data to see the effects of the filter.

Step 5: Visualize the Filter Response

It’s essential to visualize the frequency response of the filter to understand its characteristics.

Code Example

freqz(b, a);
  • This command will plot the magnitude and phase response of the filter, helping you verify if it meets your design specifications.

Conclusion

In this tutorial, you learned how to configure a Butterworth low-pass filter in MATLAB from scratch. Key steps included defining filter specifications, calculating the filter order and cutoff frequency, designing the filter, applying it to a signal, and visualizing the filter's response.

Next steps could involve experimenting with different filter parameters or applying the filter to various types of signals to see how it behaves in different scenarios.