Skip to content

Instantly share code, notes, and snippets.

@sritasngh
Created July 19, 2020 13:48
Show Gist options
  • Save sritasngh/e4ef04c7209cf73585e34c4658034c09 to your computer and use it in GitHub Desktop.
Save sritasngh/e4ef04c7209cf73585e34c4658034c09 to your computer and use it in GitHub Desktop.
Write a code in MATLAB for the single side band supressed carrier (SSB-SC) modulation scheme? Plot the spectrum (both lower and upper side bands) of the SSB-SC signal if message signal m(t)=5 cos(2 π 200t) and carrier signal c(t)= 10 cos(2 π 2000t).
%SSB-SC modulation
Am=5; %amplitude of message signal
Ac=10; %amplitude of carrier wave
fm=200; % frequency of message signal (Hz)
fc=10*fm; %frequency of carrier wave (Hz)
F=10000; %sampling frequency (Hz)
T=1/F;
t=0:T:0.025; %time vector
%1.Message signal
figure(1);
subplot(311);% plot at 1st position in a 3-by-1 grid
m=Am*cos(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
c1=cos(2*pi*fc*t);
c2=sin(2*pi*fc*t);
%3.SSB-SC modulated wave
%3.1Lower side-band SSB-SC signal
y1=m.*c1;
y2=imag(hilbert(m)).*c2;
%imag(hilbert( )) gives imaginary part of Hilbert transform
x_lsb=y1+y2;
figure(1);subplot(312);
plot(t,x_lsb); xlabel('t(sec)'); ylabel('x_l_s_b_-_s_c(t)');
title('Lower side-band SSB-SC signal Vs time');
%Spectrum of Lower side band SSB-SC signal
N=length(x_lsb);
X_lsb=fftshift(fft(x_lsb,N));
f=F*[-N/2:N/2-1]/N;
figure(2);subplot(312);
plot(f,abs(X_lsb)); xlabel('f(Hz)'); ylabel('X_l_s_b_-_s_c(f)');
title('Spectrum of Lower side-band SSB-SC signal');
%3.2 Upper side_band SSB-SC signal
x_usb=y1-y2;
figure(1);
subplot(313);
plot(t,x_usb);
xlabel('time(sec)'); ylabel('x_u_s_b_-_s_c(t)');
title('Upper side-band SSB-SC signal Vs time');
%Spectrum of Upper side band SSB-SC signal
l=length(x_usb);
X_usb=fftshift(fft(x_usb,l));
f=F*[-l/2:l/2-1]/l;
figure(2);subplot(313);
plot(f,abs(X_usb)); xlabel('f(Hz)'); ylabel('X_u_s_b_-_s_c(f)');
title('Spectrum of upper side-band SSB-SC signal');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment