EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Butterworth filter Matlab
 

Butterworth filter Matlab

Priya Pedamkar
Article byPriya Pedamkar

Updated March 4, 2023

Butterworth filter Matlab

 

 

Introduction to Butterworth filter Matlab

The following article provides an outline for Butterworth filter Matlab. Butterworth filter is used extensively in various RF and generic filter applications to get maximally flat output within the defined passband. Butterworth filter is considered as an all-round form of a filter which is adequately useful for various applications, even though it does not give the sharpest output or cut-off. When compared with other filters such as Chebyshev, the Butterworth filter tends to reach its final roll-off rate very slowly, which is also the basis of Butterworth filter, stating that the behaviour below cut-off frequencies are more important than at any other frequency.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

In Matlab we use ‘butter’ command for the purpose of implementing ‘butterworth’ filter.

Syntax:

[y, x] = butter(n, F)

[y, x] = butter(n, F, Ftype)

Description:

  • [y, x]: butter(n, F) is used to return the coefficients of transfer function for an nth-order digital Butterworth filter. This is a lowpass filter with a normalized cut off frequency of F.
  • [y, x]: butter(n, F, Ftype) is used to design any of the highpass, lowpass, bandpass, bandstop Butterworth filter. The type of filter designed depends on cut off frequency and on Ftype argument.

Examples of Butterworth filter Matlab

Given below are the examples of Butterworth filter Matlab:

Example #1

In this example, we will create a Low pass butterworth filter:

For our first example, we will follow the following steps:

  • Initialize the cut off frequency.
  • Initialize the sampling frequency.
  • For this example, we will create the Low pass butterworth filter of order 5.
  • Next, we will use the filter created in above steps to filter a random signal of 2000 samples.

Code:

F = 300

[Initializing the cut off frequency to 300]

Fs = 1000

[Initializing the sampling frequency to 1000] [y, x] = butter(5, F/(Fs/2))

[Creating the butterworth filter of order 5]

inputSignal = randn(2000, 1);

[Creating a random signal of 2000 samples]

outSignal = filter(y, x, inputSignal);

[Passing the input signal as an input to the butterworth filter created]

plot(outSignal)

[Plotting the output of the butterworth filter]

Input:

F = 300
Fs = 1000
[y, x] = butter(5, F/(Fs/2))
inputSignal = randn(2000, 1);
outSignal = filter(y, x, inputSignal);
plot(outSignal)

Output:

Butterworth filter Matlab 1

As we can see in the output, using a low pass butterworth filter we are able to filter the signal of 2000 random samples.

Example #2

In this example, we will create another Low pass butterworth filter:

For this example, we will follow the following 4 steps:

  • Initialize the cut off frequency.
  • Initialize the sampling frequency.
  • For this example, we will create the Low pass butterworth filter of order 7.
  • Next, we will use the filter created in above steps to filter a random signal of 3000 samples.

Code:

F = 600

[Initializing the cut off frequency to 600]

Fs = 1000

[Initializing the sampling frequency to 1000] [y, x] = butter(7, F/(Fs/1))

[Creating the butterworth filter of order 7]

inputSignal = randn(3000, 1);

[Creating a random signal of 3000 samples]

outSignal = filter(y, x, inputSignal);

[Passing the input signal as an input to the butterworth filter created]

plot(outSignal)

[Plotting the output of the butterworth filter]

Input:

F = 600
Fs = 1000
[y, x] = butter(7, F/(Fs/1))
inputSignal = randn(3000, 1);
outSignal = filter(y, x, inputSignal);
plot(outSignal)

Output:

we will create another Low pass

As we can see in the output, using a Low pass butterworth filter we are able to filter the signal of 3000 random samples.

In the above two examples, we have created low pass butterworth filters. Next, we will see how to create high pass butterworth filters.

Example #3

In this example, we will create a High pass butterworth filter:

For this example, we will follow the following 4 steps:

  • Initialize the cut off frequency.
  • Initialize the sampling frequency.
  • For this example, we will create the high pass butterworth filter of order 9.
  • Next, we will use the filter created in above steps to filter a random signal of 3000 samples.

Code:

F = 300

[Initializing the cut off frequency to 300]

Fs = 1000

[Initializing the sampling frequency to 1000] [z, y, x] = butter(9, F/Fs, ‘high’)

[Creating the butterworth filter of order 9. Please note that we have passed another argument ‘high’, which is used to create a high pass butterworth filter]

inputSignal = randn(3000, 1);

[Creating a random signal of 3000 samples]

outSignal = filter(z, x, inputSignal);

[Passing the input signal as an input to the butterworth filter created]

plot(outSignal)

[Plotting the output of the butterworth filter]

Input:

F = 300
Fs = 1000
[z, y, x] = butter(9, F/Fs, 'high')
inputSignal = randn(3000, 1);
outSignal = filter(z, x, inputSignal);
plot(outSignal)

Output:

Butterworth filter Matlab 3

As we can see in the output, using a high pass butterworth filter we are able to filter the signal of 3000 random samples.

Conclusion

Butterworth filters are used to get maximally flat output within the defined passband. In Matlab, we use ‘butter’ command to design a Butterworth filter. Depending upon the argument passed, we can create various filter types like low pass, high pass etc.

Recommended Articles

This is a guide to Butterworth filter Matlab. Here we discuss the introduction to Butterworth filter Matlab along with examples respectively. You may also have a look at the following articles to learn more –

  1. Cumsum MATLAB
  2. Matlab Flag
  3. Matlab Root Finding
  4. xlsread Matlab

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - ENROLL NOW