필터 지우기
필터 지우기

Problem using biquad filter object

조회 수: 1 (최근 30일)
Vincent St-Pierre
Vincent St-Pierre 2022년 11월 21일
답변: Askic V 2022년 11월 21일
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.

채택된 답변

William Rose
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.

추가 답변 (1개)

Askic V
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);

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by