Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Band pass filter problem(filtfilt)

60 views
Skip to first unread message

Anton igfne

unread,
Apr 7, 2015, 6:47:25 AM4/7/15
to
Hey!
I got a problem while designing a band pass filter,
I want to use filtfilt and then plot it, I know I have to have a input which is at least 3 times the filter order. Even if I have set a input which lives up to that requirement I get the following error massage.
"Error using filtfilt (line 78)
Not enough input arguments."

when using filt there is no problem.

(Yes I do know I use a Fs lower than design when plotting, I do that due to limit of computational force on the PC)


%function Hd = TestX1
%TESTX1 Returns a discrete-time filter object.

% MATLAB Code
% Generated by MATLAB(R) 8.5 and the DSP System Toolbox 9.0.
% Generated on: 02-Apr-2015 13:59:31

% Equiripple Bandpass filter designed using the FIRPM function.

% All frequency values are in MHz.
Fs = 20; % Sampling Frequency

Fstop1 = 4.8; % First Stopband Frequency
%4.8e6*(1/20000000)*2*pi=0.48pi normalised
Fpass1 = 4.9; % First Passband Frequency
Fpass2 = 5.1; % Second Passband Frequency
Fstop2 = 5.2; % Second Stopband Frequency
Dstop1 = 0.001; % First Stopband Attenuation
Dpass = 0.00057564620966; % Passband Ripple
Dstop2 = 0.001; % Second Stopband Attenuation
dens = 20; % Density Factor

% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fstop1 Fpass1 Fpass2 Fstop2]/(Fs/2), [0 1 ...
0], [Dstop1 Dpass Dstop2]);

% Calculate the coefficients using the FIRPM function.
b = firpm(N, Fo, Ao, W, {dens});
Hd = dfilt.dffir(b);
%freqz(Hd)


%%

rng default
length=10;
Fs = 2000;
Samples=Fs*length;
Fcenter=Fs/4;
t = linspace(0,length,Samples);
x = cos(2*pi*Fcenter*t);%+0.5*randn(size(t));
%x=[x,zeros(length(x)*2)];
y = filter(Hd,x);

plot(t(1:Samples),x(1:Samples))
hold on
plot(t(1:Samples),y(1:Samples))

yzp = filtfilt(Hd,x);
plot(t(length.yzp),yzp)
xlabel('Time (s)')
ylabel('Amplitude')
legend('Original Signal','Filtered Data')
% [EOF]
0 new messages