In: Electrical Engineering
What I am trying to do is to design a Butterworth Bandpass
filter using Matlab, High frequency must equal to 16 Hz and lower
frequency must be 10Hz (passBand). and the input signal must be a
white noise signal.
here is my code :
mu=0;
sigma=2;
X= sigma*randn(500,1)+mu; %Generating White Noise signal
Fs=500;%Sampling Frequency
Fh= 16;
Fl=10;
order=6;
[b,a]=butter(order,[Fh Fl]/(Fs/2),'bandpass');%Butterworth BandPass filter
XX=filtfilt(b,a,X);%filter the signal both forward and backword in time
Actually, I am not sure about Fs value that I have chosen and I do not know the criteria of choosing it for such a filter.Moreover, I am getting Weird plot when trying to plot XX "it may be correct though".
Hi,
According to the sampling therom the Sampling Frequency must be two greater than the original signal.
Here you are generating white noise which is broadband signal. So when you are applying Butterworth filter you are loosing your original signal because of undersampling.
You can use the Band Limited White noise signal to get accurate results.
or you can generate the signal and add that noise to it and apply butterworth filter to it to check the results.
-----------------------------------------------------------------------------------------------------------------------------------------------
len = 500; % Length (sec) f = 1024; % Frequency (Hz) Fs = 2048; % Sampling Frequency (Hz) t = linspace(0, len, Fs*len); % Time Vector
signal = sin(2*pi*f*t); % Signal (1 k
noise = signal + 0.1*randn(size(signal));
%mu=0;
%sigma=2;
%X= sigma*randn(500,1)+mu; %Generating White Noise signal
%Fs=500;%Sampling Frequency
Fh= 16;
Fl=10;
order=6;
[b,a]=butter(order,[Fh Fl]/(Fs/2),'bandpass');%Butterworth BandPass filter
XX=filtfilt(b,a,noise);%filter the signal both forward and backword in time