You are on page 1of 7

Problem (3.3).

T_sample = 0.0001;
f_sample = 1/T_sample;
N_sample = 16000;
t0 = 0.1;
fc = 250;

t = -((N_sample/2)-1)*T_sample:T_sample:(N_sample/2)*T_sample;
m = 0*t;
for i=1:N_sample
if(0<=(i-(N_sample/2))*T_sample)&&(((i-(N_sample/2))*T_sample)<=t0);
m(i) = sinc(100*(i-(N_sample/2))*T_sample);
end
end
subplot(4,4,1);
plot(t,m);
title('Message signal with t0 = 0.1');
xlabel('Time(Sec)');
ylabel('Amplitude');
axis([-0.8 0.8 -2 2]);

M = fft(m)*T_sample;
freq = (0:N_sample-1)*f_sample/N_sample;
Mshift = fftshift(M);
fshift = (-N_sample/2:N_sample/2-1)*(f_sample/N_sample);
subplot(4,4,5);
plot(fshift,abs(Mshift));
title('Message spectrum M(f)');
xlabel('Frequency (Hz)');
ylabel('Magitude');
axis([-500 500 0 0.02]);
subplot(4,4,9);
plot(fshift,angle(Mshift));
axis([-500 500 -pi pi]);
title('Phase of Message Spectrum');
xlabel('Frequency (Hz)');

m2 = f_sample*ifft(fftshift(Mshift));
subplot(4,4,13);
plot(t,m2);
title('Reconstructed m(t) with t0 = 0.1');
xlabel('Time(sec)');
axis([-0.8 0.8 -2 2]);

% HILBERT TRANSFORM OF MESSAGE mhat(t)


% USE FREQUENCY DOMAIN STARTING FROM M(f)
% GENERATE THE SPECTRUM of mhat from Mshift (spectrum of m)
for i=1:N_sample
if fshift(i) < 0
MshiftHAT(i) = j*Mshift(i);
elseif fshift(i) == 0
MshiftHAT(i) = Mshift(i);
else MshiftHAT(i) = -j*Mshift(i);
end
end
subplot(4,4,2);
plot(fshift,abs(MshiftHAT));
axis([-500 500 0 0.02]);
title('Magnitude of mhat Spectrum');
xlabel('Frequency (Hz)');
subplot(4,4,6);
plot(fshift,angle(MshiftHAT));
axis([-500 500 -pi pi]);
title('Phase of mhat Spectrum');
xlabel('Frequency (Hz)');

% USE INVERSE FOURIER TRANFORM TO OBTAIN TIME SIGNAL!!!


mhat = f_sample*ifft(fftshift(MshiftHAT));
subplot(4,4,10);
plot(t,real(mhat));
title('Hilbert transform mhat(t) with t0 = 0.1');
xlabel('Time (sec)');
axis([-((N_sample/2)-1)*T_sample (N_sample/2)*T_sample -2 2]);
% CARRIER AND ITS TRANSFORM
% THE CARRIER SIGNAL c(t) = cos(2*pi*fc*t)
for i=1:N_sample
c(i) = cos(2*pi*fc*(i-(N_sample/2))*T_sample) ;
end
subplot(4,4,3); plot(t,c);
title('Carrier Signal c(t)');
xlabel('Time (sec)');
axis([-((N_sample/2)-1)*T_sample (N_sample/2)*T_sample -2 2]);
% CARRIER FREQUENCY SPECTRUM
C = fft(c)*T_sample;
freq = (0:N_sample-1)*f_sample/N_sample;
Cshift = fftshift(C); fshift = (-N_sample/2:N_sample/2-
1)*(f_sample/N_sample);
subplot(4,4,7); plot(fshift,abs(Cshift));
axis([-500 500 0 1]);
title('Magnitude of Carrier Spectrum');
% Looking at phase spectrum and imaginary parts of Cshift...
% needs clean up after the fft.
%Set small magnitude values to 0 phase
CshiftMAXMAG = max(abs(Cshift));
for i=1:N_sample
if abs(Cshift(i))< 0.01*CshiftMAXMAG
CshiftANGLE(i) = 0;
else
CshiftANGLE(i) = angle(Cshift(i));
end
end
subplot(4,4,11);
plot(fshift,CshiftANGLE);
axis([-500 500 -pi pi]);
title('Phase of Carrier Spectrum');
ylabel('Magnitude');
xlabel('Frequency (Hz)');
% MODULATED SIGNAL AND ITS TRANSFORM
% FIRST CLEAN UP mhat TO REMOVE inaginary noise terms
mhatR = real(mhat);
uL = c.*m+mhatR.*sin(2*pi*fc*t);
% for Lower SSB
subplot(4,4,4); plot(t,uL);
title('Transmitted LSSB uL(t)');
xlabel('Time (sec)');
axis([-((N_sample/2)-1)*T_sample (N_sample/2)*T_sample -2 2]);
% SPECTRAL ANALYSIS OF LSSB uL(t) SIGNAL
UL = fft(uL)*T_sample;
freq = (0:N_sample-1)*f_sample/N_sample;
ULshift = fftshift(UL);
fshift = (-N_sample/2:N_sample/2-1)*(f_sample/N_sample);
subplot(4,4,8);
plot(fshift,abs(ULshift));
axis([-500 500 0 0.02]);
title('Magnitude of Transmitted Spectrum UL(f)');
xlabel('Frequency (Hz)');
% CLEAN UP THE PHASE GRAPH WHEN OUTSIDE +- 250 Hz
for i=1:N_sample
if abs(fshift(i))> 250
ULshiftANGLE(i) = 0;
else
ULshiftANGLE(i) = angle(ULshift(i));
end
end
subplot(4,4,12);
plot(fshift,ULshiftANGLE);
axis([-500 500 -pi pi]);
title('Phase of Transmitted Spectrum UL(f)');
xlabel('Frequency (Hz)');

SSB when t=0.1:


SSB when t0 = 0.4:

Problem 3.4:

MATLAB Code:
T_sample = 0.0001;
f_sample = 1/T_sample;
N_sample = 16000;
t0 = 0.1;

t = -((N_sample/2)-1)*T_sample:T_sample:(N_sample/2)*T_sample;
m = 0*t;
for i=1:N_sample
if(-t0<=(i-(N_sample/2))*T_sample)&&(((i-(N_sample/2))*T_sample)<=t0);
m(i) = sinc(100*(i-(N_sample/2))*T_sample);
end
end
subplot(2,3,1);
plot(t,m);
title('Original Message signal m(t)');
xlabel('Time(Sec)');
ylabel('Amplitude');
axis([-0.8 0.8 -2 2]);

fc = 250;
for i=1:N_sample
c(i) = cos(2*pi*fc*(i-(N_sample))*T_sample);
end
subplot(2,3,2);
plot(t,c);
title('Carrier signal with c(t)');
xlabel('Time(Sec)');
ylabel('Amplitude');
axis([-0.8 0.8 -2 2]);

a = 0.8;
u = (1+a*m).*c;
subplot(2,3,3);
plot(t,u);
title('Modulated signal with u(t)');
xlabel('Time(Sec)');
ylabel('Amplitude');
axis([-0.8 0.8 -2 2]);

%Demodulation
s1 = u.*c;
b = fir1(30,0.02,'low',chebwin(31,3));
output = filtfilt(b,1,s1);
subplot(2,3,4);
plot(t,output);
title('Reconstructed signal mr(f)');
xlabel('Frequency (Hz)');
ylabel('Magitude');
axis([-0.8 0.8 -2 2]);

S1 = fft(s1)*T_sample;
freq = (0:N_sample-1)*f_sample/N_sample;
Sshift = fftshift(S1);
fshift = (-N_sample/2:N_sample/2-1)*(f_sample/N_sample);
subplot(2,3,5);
plot(fshift,abs(Sshift));
title('Received Signal spectrum R(f)');
xlabel('Frequency (Hz)');
ylabel('Magitude');
axis([-500 500 0 0.02]);

MR = fft(output)*T_sample;
freq = (0:N_sample-1)*f_sample/N_sample;
Sshift = fftshift(MR);
fshift = (-N_sample/2:N_sample/2-1)*(f_sample/N_sample);
subplot(2,3,6);
plot(fshift,abs(Sshift));
title('Reconstructed message Signal spectrum MR(f)');
xlabel('Frequency (Hz)');
ylabel('Magitude');
axis([-500 500 0 0.02]);
Part3:

Reconstructed signal mr(f) is shown in above figure. If we change phase of carrier in


multiplier at receiving end then the only change is in phase of the received signal. As we plotted
the magnitudes in above figure so change in magnitudes. All other requirements of filter are
shown in filter design in matlab code. Built in function ‘filtfilt’ is used which doesn’t change
phase of signal being filtered.

The frequency domain spectrum of reconstructed message signal is given at (2,3,6) position of
above figure. It is almost same as of original signal anyhow there is some noise.

You might also like