フィルターのクリア

Artefacts when filtering a contiguous signal

5 ビュー (過去 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)
  1 件のコメント
rocketMan
rocketMan 2022 年 9 月 15 日
Thank you so much!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by