![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1201253/image.png)
Problem using biquad filter object
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Vincent St-Pierre
il 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 :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1201133/image.png)
The frequency shift succeeded but the filter is not behaving like intended and is just attenuating everything.
0 Commenti
Risposta accettata
William Rose
il 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1201253/image.png)
Try it. Good luck.
0 Commenti
Più risposte (1)
Askic V
il 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 Commenti
Vedere anche
Categorie
Scopri di più su Multirate Signal Processing 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!