Script:
clc;clear all;close all;
%Message signal
fs=40000
t=0:1/fs:0.01;
fm=1000;
Am=sin(2*pi*fm*t);%low frequency cosine signal
fc=10000;
Ac=cos(2*pi*fc*t);%high frequency cosine signal
%Amplitude modulation
N=1024;f=[-fs/2:fs/N:fs/2-fs/N];
xAM=Am.*Ac;
f=[-fs/2:fs/N:fs/2-fs/N];
%Frequency domain of AM
figure;
subplot(311)
plot(f,fftshift(abs(fft(Am,N))),'b') ;
title('Fourier transform of Modulated signal');
xlabel('f in Hz');ylabel('XAM(f)');grid on;
xlim([-5000,5000])
%Demodulation
demod = xAM.*cos(2*pi*fc*t);
subplot(312)
plot(f,fftshift(abs(fft(demod,N))),'m') ;
title('Fourier transform of demodulated signal');
xlabel('f in Hz');ylabel('XDEMOD(f)');grid on;
xlim([-5000,5000])
%Filter design to recover message signal
[num den] = butter(5,fc*2/fs);
mf = filtfilt(num,den,demod).*2;
subplot(313)
plot(t,mf,'r','LineWidth',3,t,Am,'--b','LineWidth',3);grid
on;
title('Demodulation ')
xlabel('t(s)')
legend('demodulated signal','Original message signal')
Get Answers For Free
Most questions answered within 1 hours.