Bandstop filter in matlab

Status
Not open for further replies.

Majid_Vatan_Parast

Junior Member level 3
Joined
Oct 15, 2016
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,498
Hello everybody
I need to design a Bandstop filter with MATLAB , but I do not what to do :sad: .
Can anyone help me please?
Thanks
 

Combination of LP + HP filter?

Code:
fsHz = 1e3;
N = 5e2;

x = randn(N, 1) + 1j * randn(N, 1);

%% LP definition
Fs = 1;  % Sampling Frequency
Fpass = 0.1;             % Passband Frequency
Fstop = 0.15;            % Stopband Frequency
Dpass = 0.057501127785;  % Passband Ripple
Dstop = 0.001;           % Stopband Attenuation
dens  = 20;              % Density Factor
[N, Fo, Ao, W] = firpmord([Fpass, Fstop]/(Fs/2), [1 0], [Dpass, Dstop]);
bLow = firpm(N, Fo, Ao, W, {dens}).';

% HP definition
Fs = 1;  % Sampling Frequency
Fstop = 0.25;            % Stopband Frequency
Fpass = 0.3;             % Passband Frequency
Dstop = 0.001;           % Stopband Attenuation
Dpass = 0.057501127785;  % Passband Ripple
dens  = 20;              % Density Factor
[N, Fo, Ao, W] = firpmord([Fstop, Fpass]/(Fs/2), [0 1], [Dstop, Dpass]);
bHigh = firpm(N, Fo, Ao, W, {dens}).';


bLen = max(numel(bLow), numel(bHigh));
bLow = padarray(bLow, bLen - numel(bLow), 0, 'post');
bHigh = padarray(bHigh, bLen - numel(bHigh), 0, 'post');
b = bLow + bHigh;

% Filter
xFilt = filter(b, 1, x);

figure(101);
subplot(2, 1, 1);
periodogram(x, [], [], fsHz);
title('Ori');
subplot(2, 1, 2);
periodogram(xFilt, [], [], fsHz);
title('BSF');
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…