Problem using biquad filter object
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vincent St-Pierre
le 21 Nov 2022
Réponse apportée : Askic V
le 21 Nov 2022
I have the following code to demodulate AM signal using frequency shifting and filtering :
clc;clear all;
Fs=44100; Ts=1/Fs;
t=0:Ts:4;
s1=cos(2*pi*60*t);
carrier=cos(2*pi*1000*t);
smod=s1.*carrier;
N = 2; % Order
Fpass = 100; % Passband Frequency
Apass = 1; % Passband Ripple (dB)
Fs = 44100; % Sampling Frequency
h = fdesign.lowpass('n,fp,ap', N, Fpass, Apass, Fs);
Hd = design(h, 'cheby1','SystemObject', true);
sdemod = smod.*carrier;
sdemod2 = Hd(sdemod);
Now, when I use the Signal Analyser to see the result I have this :
The frequency shift succeeded but the filter is not behaving like intended and is just attenuating everything.
0 commentaires
Réponse acceptée
William Rose
le 21 Nov 2022
I'm not sure why your code does not work, but a simple 4th order Butterworth works fine. See code below.
Fs = 44100; % sampling rate (Hz)
Ts=1/Fs; t=0:Ts:4;
s1=cos(2*pi*60*t);
carrier=cos(2*pi*1000*t);
smod=s1.*carrier;
N=4; % filter order
Fpass = 100; % passband frequency (Hz)
[b,a]=butter(N,Fpass/(Fs/2)); % Butterworth filter coefficients
sdemod = smod.*carrier;
sdemod2=filter(b,a,sdemod); % apply lowpass filter to sdemod
Here is a screen shot of the power spectra of the signals, from signalAnalyzer:
Try it. Good luck.
0 commentaires
Plus de réponses (1)
Askic V
le 21 Nov 2022
Even better, I would use filtfilt function in order to have zero lag:
clc;clear all;
Fs=44100; Ts=1/Fs;
t=0:Ts:0.2;% to beeter see it on plot
s1=cos(2*pi*60*t);
carrier=cos(2*pi*1000*t);
smod=s1.*carrier;
N = 2; % Order
Fpass = 100; % Passband Frequency
Apass = 1; % Passband Ripple (dB)
[b,a] = cheby1(N, Apass, Fpass*2/Fs);
sdemod = smod.*carrier;
sdemod2 = 2*filtfilt(b,a, sdemod);
subplot(311)
plot(t, s1);
subplot(312)
plot(t, smod);
subplot(313)
plot(t, sdemod2);
0 commentaires
Voir également
Catégories
En savoir plus sur Multirate Signal Processing 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!