EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • All Courses
    • All Specializations
  • Blog
  • Enterprise
  • Free Courses
  • All Courses
  • All Specializations
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Bandpass Filter Matlab
 

Bandpass Filter Matlab

Priya Pedamkar
Article byPriya Pedamkar

Updated June 23, 2023

Bandpass Filter Matlab

 

 

Introduction to Bandpass Filter Matlab

Band-pass filters are electronic circuits or devices that engineers use to filter or isolate certain frequencies within a particular range. These filters find applications in various systems, such as audio amplifiers, loudspeakers (crossover filters), and pre-amplifiers for tone controls. In such applications, engineers need to pass only a specific range of frequencies, which does not start at DC (0 Hz) or extend to higher frequencies but lies within a particular range, which can be either wide or narrow.

Watch our Demo Courses and Videos

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

Syntax:

F = bandpass (s, wp)

F = bandpass (s, fp, Fx)

Description:

  • F = bandpass(s, wp) filters the signal ‘s’ with passband frequency range provided by the 2-element vector ‘wp.’ If input ‘s’ is a matrix, the bandpass function will filter each column of ‘s’ independently.
  • F = bandpass (s, fp, Fx) is used to specify that the signal ‘s’ is sampled at a rate ‘Fx’ HZ. The 2-element vector ‘fp’ gives the passband frequency.

Examples of Bandpass Filter Matlab

Let us now understand the code of ‘Bandpass filter’ in MATLAB with the help of various examples:

Example #1

In this example, we will create a sine signal which is sampled at 10000Hz for 1 second and will pass it through a Bandpass filter.

Below are the steps to be followed:

  • Define the sampling rate.
  • Define the tones for the signal.
  • Keep low-frequency and high-frequency tones at a level of three times the intermediate tone.
  • Pass the above signal through the bandpass filter by setting the allowed frequencies.

Code:

Fx = 1e4
T = 0:1/Fx:1

[Defining the sampling rate]

s = [3 1 3]*sin(pi*[50 100 300]'.*T) + randn(size(T))/20;

[Creating the signal with 3 tones, 50 Hz, 100 Hz, and 300 Hz]

bandpass(s, [100 200], Fx)

[Passing the input signal to a bandpass filter and setting the allowed frequency range as 100 to 200] [Bandpass filter will allow frequencies of 100 & 200 Hz. In the output, we will get the original & filtered signals along with their spectra]

Input:

Fx = 1e4
T = 0:1/Fx:1
s = [3 1 3]*sin(pi*[50 100 300]'.*T) + randn(size(T))/20;
bandpass(s, [100 200], Fx)

Output:

As we can see in the output, we have obtained the original & filtered signals along with their spectra. The Bandpass filter has removed the frequencies below the low pass frequency and frequencies above the high pass frequency.

Bandpass Filter Matlab-1.1

Example #2

In this example, we will create a cos signal which is sampled at 10000Hz for 1 second and will pass it through a Bandpass filter.

Below are the steps to be followed:

  • Define the sampling rate.
  • Define the tones for the signal.
  • Keep low-frequency and high-frequency tones at a level of two times the intermediate tone.
  • Pass the above signal through the bandpass filter by setting the allowed frequencies.

Code:

Fx = 1e4
T = 0:1/Fx:1

[Defining the sampling rate]

s = [2 1 2]*cos(pi*[150 200 300]'.*T) + randn(size(T))/20;

[Creating the cos signal with 3 tones, 150 Hz, 200 Hz, and 300 Hz]

bandpass(s, [100 200], Fx)

[Passing the input signal to a bandpass filter and setting the allowed frequency range as 100 to 200] [Bandpass filter will allow frequencies of 100 & 200 Hz. In the output, we will get the original & filtered signals along with their spectra]

Input:

Fx = 1e4
T = 0:1/Fx:1
s = [2 1 2]*cos(pi*[150 200 300]'.*T) + randn(size(T))/20;
bandpass(s, [100 200], Fx)

Output:

Image-1.2

As we can see in the output, we have obtained the original & filtered signals for our input cos signal along with their spectra. The Bandpass filter has removed the frequencies below the low pass frequency and frequencies above the high pass frequency.

Example #3

In the above 2 examples, we used a three-channel signal; in this example, we will use a 2-channel signal and pass it through a Bandpass filter.

  • Define the sampling rate.
  • Define the tones for the signal.
  • Keep the high frequency twice the low frequency.
  • Pass the above signal through the bandpass filter by setting the allowed frequencies.

Code:

Fx = 1e4
T = 0:1/Fx:1

[Defining the sampling rate]

s = [2 1].*cos(2*pi*(0:64)'./[32 64])

[Creating the 2-channel cos signal]

bandpass(s, [100 200], Fx)

[Passing the input signal to a bandpass filter and setting the allowed frequency range as 100 to 200] [Bandpass filter will allow frequencies of 100 & 200 Hz. In the output, we will get the original & filtered signals along with their spectra]

Input:

Fx = 1e4
T = 0:1/Fx:1
s = [2 1].*cos(2*pi*(0:64)'./[32 64])
bandpass(s, [100 200], Fx)

Output:

Image-1.3

As we can see in the output, we have obtained the original & filtered signals for our input cos signal along with their spectra. The Bandpass filter has removed the frequencies below the low pass frequency and frequencies above the high pass frequency.

Conclusion

  • We use the Bandpass function in MATLAB to execute a Bandpass filter.
  • The Bandpass function in MATLAB provides both original and filtered signals as output.
  •  This function also provides the spectra of the signals in the output.

Recommended Articles

This is a guide to Bandpass Filter Matlab. Here we also discuss the introduction and syntax of bandpass filter matlab along with a different example and its code implementation. You may also have a look at the following articles to learn more –

  1. Matlab Format
  2. Moving Average Matlab
  3. Convolution Matlab
  4. Magnitude 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
EDUCBA

*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

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

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 Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW