Artefacts when filtering a contiguous signal
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Jan
le 15 Sep 2022
Modifié(e) : Jan
le 15 Sep 2022
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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Filter Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!