Low pass filter for amplitude modulation
36 views (last 30 days)
Show older comments
I was writting a code of AM DSBSC .
Here is the ouput graph
- Information signal
- Carrier*information signal
- demodulated signal
Now the demodulated signal needs to be passed through a low pass filter .I was using the lowpass function but I am not getting the ouput I need.Th output should be the red graph.
Please tell me where I am wrong?
Thank you.
here is my code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=0:1e-4:0.5;
f=5;
y=sin(2*pi*f*t);
subplot(3,1,1)
plot(t,y)
hold on
yline(0)
xline(0.2)
ylim([-2 2])
hold off
subplot(3,1,2)
y1=sin(2*pi*100*t);
y3=y1.*y;
plot(t,y3)
hold on
yline(0)
hold off
subplot(3,1,3)
y4=y3.*sin(2*pi*100*t);
y5=lowpass(y4,1,1e4)
plot(t,y5)
hold on
ylim([-2 2])
plot(t,y);
hold off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0 Comments
Answers (1)
Mathieu NOE
on 19 Oct 2020
hi
my suggestion below (tested OK)
dt = 1e-4;
Fs = 1/dt;
t=0:dt:0.5;
f=5;
y=sin(2*pi*f*t);
subplot(3,1,1)
plot(t,y)
hold on
yline(0)
xline(0.2)
ylim([-2 2])
hold off
subplot(3,1,2)
y1=sin(2*pi*100*t);
y3=y1.*y;
plot(t,y3)
hold on
yline(0)
hold off
subplot(3,1,3)
y4=y3.*sin(2*pi*100*t);
[BlpFilt,AlpFilt] = butter(4,0.01);
y5 =filter(BlpFilt,AlpFilt,y4);
plot(t,y5,'r')
hold on
ylim([-2 2])
plot(t,y);
hold off
2 Comments
Mathieu NOE
on 20 Oct 2020
hello
because for y5 we used the function "filter" so the demodulated signal is phase shifted from the original signal (y)
to avoid this phase shift I replaced "filter" with "filtfilt" so no more phase shift
also I increased the amplitude of the y5 signal so that now both traces superposed well.
see pictures attached
new code below :
clc
close all
dt = 1e-4;
Fs = 1/dt;
t=0:dt:0.5;
f=5;
y=sin(2*pi*f*t);
subplot(3,1,1)
plot(t,y)
hold on
yline(0)
xline(0.2)
ylim([-2 2])
hold off
subplot(3,1,2)
y1=sin(2*pi*100*t);
y3=y1.*y;
plot(t,y3)
hold on
yline(0)
hold off
subplot(3,1,3)
y4=y3.*sin(2*pi*100*t);
% y5=lowpass(y4,1,1e4)
[BlpFilt,AlpFilt] = butter(4,0.01);
% y5 =filter(BlpFilt,AlpFilt,y4);
y5 =filtfilt(BlpFilt,AlpFilt,y4);
plot(t,2*y5,'-*r')
hold on
ylim([-2 2])
plot(t,y);
hold off
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!