Matlab – Lowpass/Bandpass filter design in MATLAB

communicationlowpass-filterMATLAB

For an analog communication system design in MATLAB firstly I need to do these two design:

  1. Design a low-pass filter [slow]=lowpassfilter(s,fcut,fs) which filters input signal s with cutoff frequency fcut and sampling frequency fs in Hertz.

  2. Design a band-pass filter [sband]=bandpassfilter(s,fcutlow,fcuthigh,fs) which filters input signal s with cutoff frequencies fcutlow and fcuthigh and sampling frequency fs in Hertz.

Could you please help me?

Best Answer

I found this question which has so many views and still no good answer.

The following code will do what you need. Since no filter-type is specified, I used a butterworth-filter to demonstrate it. s is the input signal and x is the filtered signal. fs is the sampling rate in Hz.

% Design and apply the lowpass filter
order = 4;
fcut  = 8000;
[b,a] = butter(order,fcut/(fs/2),'low');
x     = filter(b,a,s);


% Design and apply the bandpass filter
order    = 10;
fcutlow  = 1000;
fcuthigh = 2000;
[b,a]    = butter(order,[fcutlow,fcuthigh]/(fs/2), 'bandpass');
x        = filter(b,a,s);
Related Topic