How to correctly apply dsp.FIRFilter

8 visualizzazioni (ultimi 30 giorni)
Kera Cai il 3 Apr 2024
Commentato: Kera Cai il 15 Apr 2024
The code is simple:
N = 40;
fs = 20 * 10 ^ 9;
freq = [0, 1 * 10 ^ 9, 2 * 10 ^ 9, 3 * 10 ^ 9, 5 * 10 ^ 9, 7.5 * 10 ^ 9, 10 * 10 ^ 9]
mag = [1, 1, 1, 0.3, 0.1, 0.005, 0.001]
d = fdesign.arbmag('N,F,A', N, freq, mag, fs);
W = [1, 1, 1, 1, 1, 1, 1];
fir = design(d, 'equiripple', 'weights', W, 'SystemObject', true);
sents = ones(1, 300) * amplitude;
rcvds = fir(sents);
% plot
figure(1)
stem(sents)
hold on
stem(rcvds)
legend('sents', 'received')
By viewing freqz(fir), seems the filter is correctly designed, it's low pass:
But in the code I input a DC signal, the result does not seem to be correct, the output is almost 0.
Is the way I perform the filter wrong?
Seems I got correct result when apply the filter by function filter:
fir = fir.Numerator
rcvds = filter(fir, 1, sents)
figure(2)
stem(sents)
hold on
stem(rcvds)
legend('sents', 'received')
1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Kera Cai il 7 Apr 2024
I did not really get that. Static or time-varying FIR filter - MATLAB (mathworks.com), this page says to apply a dsp.FIRFilter object fir: y = fir(x) to get the output.

Accedi per commentare.

Risposta accettata

Paul il 7 Apr 2024
The input to fir() should be a column vector.
N = 40;
fs = 20 * 10 ^ 9;
freq = [0, 1 * 10 ^ 9, 2 * 10 ^ 9, 3 * 10 ^ 9, 5 * 10 ^ 9, 7.5 * 10 ^ 9, 10 * 10 ^ 9];
mag = [1, 1, 1, 0.3, 0.1, 0.005, 0.001];
d = fdesign.arbmag('N,F,A', N, freq, mag, fs);
W = [1, 1, 1, 1, 1, 1, 1];
fir = design(d, 'equiripple', 'weights', W, 'SystemObject', true);
sents = ones(1, 300);% * amplitude;
rcvds = fir(sents.');
% plot
figure(1)
stem(sents)
hold on
stem(rcvds)
legend('sents', 'received')
1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Kera Cai il 15 Apr 2024
Thank you!

Accedi per commentare.

Categorie

Scopri di più su Single-Rate Filters in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by