Lowpass/Bandpass filter design in MATLAB
Solution 1
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);
Solution 2
Matlab has fdatool
for filter design purposes. Here is the documentation. You can do all these tasks using fdatool
and the signal processing toolbox.
Çiğdem Özer
Hacettepe University/ Electrical and Electronics Engineering / Student
Updated on March 26, 2020Comments
-
Çiğdem Özer about 4 years
For an analog communication system design in MATLAB firstly I need to do these two design:
Design a low-pass filter
[slow]=lowpassfilter(s,fcut,fs)
which filters input signals
with cutoff frequencyfcut
and sampling frequencyfs
in Hertz.Design a band-pass filter
[sband]=bandpassfilter(s,fcutlow,fcuthigh,fs)
which filters input signals
with cutoff frequenciesfcutlow
andfcuthigh
and sampling frequencyfs
in Hertz.
Could you please help me?