![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1201253/image.png)
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 :
![](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
채택된 답변
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1201253/image.png)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!