
Problem using biquad filter object
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
William Rose
2022-11-21
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 个评论
更多回答(1 个)
Askic V
2022-11-21
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 个评论
另请参阅
类别
Find more on Digital Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!