Skip to content

Instantly share code, notes, and snippets.

@sritasngh
Created July 21, 2020 13:21
Show Gist options
  • Save sritasngh/489972c672ae044b9336190813c68123 to your computer and use it in GitHub Desktop.
Save sritasngh/489972c672ae044b9336190813c68123 to your computer and use it in GitHub Desktop.
Write a code in MATLAB to obtain output form the expression for the amplitude modulation (DSB-C) signals, where message signal is m(t)=5 sin(2 π 100t) and carrier signal c(t)= 10 sin(2 π 1500t).
%DSB-C modulation
Am=5; %amplitude of message signal
Ac=10; %amplitude of carrier wave
m_i=Am/Ac; %modulation index
fm=100; %frequency of message signal (Hz)
fc=1500; %frequency of carrier wave (Hz)
F=10000; %sampling frequency (Hz)
T=1/F;
t=0:T:0.05; %time vector
%1.Message signal
figure(1);
subplot(311); %plot at 1st position in a 3-by-1 grid
m=Am*sin(2*pi*fm*t);
plot(t,m); xlabel('t(sec)'); ylabel('m(t)');
title('Message signal Vs Time');
%Spectrum of message signal
n=length(m); %length returns period of the message signal
M=fftshift(fft(m,n)); %zero-centered fast fourier transform
f=F*[-n/2:n/2-1]/n; %zero-centered frequency range
figure(2);subplot(311);
plot(f,abs(M));xlabel('f(Hz)'); ylabel('M(f)');
title('Spectrum of Message signal');
%2.Carrier wave
c=Ac*sin(2*pi*fc*t);
figure(1);
subplot(312); %creates axis at 2nd place on a 3-by-1 grid
plot(t,c); xlabel('t(sec'); ylabel('c(t)');
title('Carrier signal Vs Time')
%Spectrum of carrier wave
N=length(c);
C=fftshift(fft(c,N));
f=F*[-N/2:N/2-1]/N;
figure(2);subplot(312);
plot(f,abs(C)); xlabel('f(Hz)'); ylabel('C(f)');
title('Spectrum of Carrier wave');
%3.DSB-C modulation
x_dsbc=c.*(1+m_i.* sin(2*pi*fm*t)); %DSB-C signal
figure(1);
subplot(313);
plot(t,x_dsbc);xlabel('t(sec)'); ylabel('x_d_s_b_-_c(t)');
title('DSB-C signal Vs Time');
%Spectrum of DSB-C modulated signal
l=length(x_dsbc);
X_dsbc=fftshift(fft(x_dsbc,l));
figure(2);
subplot(313);
plot(f,abs(X_dsbc));
xlabel('f(Hz)');ylabel('X_d_s_b_-_c(f)');
title('Spectrum of DSB-C modulated signal');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment