フィルターのクリア

LINEAR PHASE FIR DESIGN

2 ビュー (過去 30 日間)
shalini singh
shalini singh 2020 年 7 月 28 日
編集済み: Walter Roberson 2020 年 7 月 28 日
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

回答 (0 件)

カテゴリ

Help Center および File ExchangeFilter Design についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by