Azzera filtri
Azzera filtri

LINEAR PHASE FIR DESIGN

2 visualizzazioni (ultimi 30 giorni)
shalini singh
shalini singh il 28 Lug 2020
Modificato: Walter Roberson il 28 Lug 2020
I'm designing a low pass linear phase fir filter. To get coefficients i used park mcclellan algorithm. my filter impulse response is not constant 0db in passband but has ripples. I'm adding my own filter code and coefficients and picture of the impulse response.
please tell me where is the proplem.
%%input
x_impulse=zeros(1,256);
x_impulse(1)=1;
%%coefficients
function b = coef
%COEF Returns a discrete-time filter object.
% MATLAB Code
% Generated by MATLAB(R) 9.8 and DSP System Toolbox 9.10.
% Generated on: 28-Jul-2020 07:00:26
% Equiripple Lowpass filter designed using the FIRPM function.
% All frequency values are normalized to 1.
Fpass = 0.3; % Passband Frequency
Fstop = 0.542; % Stopband Frequency
Dpass = 5.7564627261e-05; % Passband Ripple
Dstop = 0.001; % Stopband Attenuation
dens = 20; % Density Factor
% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fpass, Fstop], [1 0], [Dpass, Dstop]);
% Calculate the coefficients using the FIRPM function.
b = firpm(N, Fo, Ao, W, {dens});
Hd = dfilt.dffir(b);
% [EOF]
%%filter code
function [y] = LFIR(x,b)
y=zeros(size(x));
z=zeros(1,2);
e=0.001;
for n = 1 : length(x)
acc=0;
for k = 1 : length(b)
if 1+ n-k>0
z(1,1)=x(1+n-k);
end
if 1+n-length(x)+k>0
z(1,2)=x(1+n-length(x)+k);
end
acc=acc+b(1,k)*((z(1,1)+z(1,2)));
z(1,1)=0+e;
z(1,2)=0+e;
end
y(n)=acc;
end
end

Risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by