Artefacts when filtering a contiguous signal

조회 수: 1 (최근 30일)
rocketMan
rocketMan 2022년 9월 15일
편집: Jan 2022년 9월 15일
Hello,
I have a signal vector vec (54 sampling points). That looks like that:
vec = [5 8 10 8 5 3 1 3 5];
vec = [vec vec vec vec vec vec];
When I filter it with a lowpassfilter, it looks like that (Fig1):
Code for the filtering is:
h = fdesign.lowpass('fp,fst,ap,ast', 0.10, 1, 1, 60);
Hd = design(h, 'equiripple');
c = filter(Hd,vec);
plot(c);
Now, I want to split the sample in zwo sections and filter them separately. As a result, I want to get the same result as in Fig1.
I tried this code:
% design filter
h = fdesign.lowpass('fp,fst,ap,ast', 0.10, 1, 1, 60);
Hd = design(h, 'equiripple');
% split signal in two sections
vec1 = vec(1:27);
vec2 = vec(28:54);
% define numerator, denominator and initial conditions for filter delay
num = Hd.Numerator;
den = 1;
zi = vec1(end-2:end);
% filter the two sections
c1 = filter(num,den,vec1);
c2 = filter(num,den,vec2,zi);
% concatenate and plot the filtered sections
c = [c1 c2];
plot(c);
but get artefacts in the plot:
Could someone tell me what am I doing wrong?
Best regards,
Rocketman

채택된 답변

Jan
Jan 2022년 9월 15일
편집: Jan 2022년 9월 15일
The final state of the filter parameters after the 1st block is not the value of the signal. Replace:
zi = vec1(end-2:end); % Nope
c1 = filter(num, den, vec1);
c2 = filter(num, den, vec2, zi);
by
[c1, zf] = filter(num, den, vec1);
c2 = filter(num, den, vec2, zf);
There are still tiny differences in the magnitude of 1e-15 caused by rounding, because the implementations differ slightly:
c1 = filter(Hd, vec);
c2 = filter(Hd.Numerator, 1, vec)
plot(c1 - c2)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Filter Analysis에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by