Professional Documents
Culture Documents
clear all;
close all;
clf;
QUESTION 1&2
for i=time
if i<-Tsym/2 || i>Tsym/2 % generate one rectangular pulse with
rect(t) = 0 ; % pulse width T/4
else
rect(t) = 1;
end
sinc0(t) = sinc(i/Tsym);
t=t+1;
end
t=1;
for i=time
sinc1(t) = sinc(3*i/Tsym);
t=t+1;
end
t=1;
for i=time
sinc2(t) = sinc(i/(4*Tsym));
t=t+1;
end
1
plotting of the pulse shaping signals
figure;
plot(time,rect,'r','Linewidth',2);hold on;
plot(time,sinc0,'g','Linewidth',2);hold on;
plot(time,sinc1,'b','Linewidth',2);hold on;
plot(time,sinc2,'y','Linewidth',2);hold on;
title('PULSE SHAPPING SIGNAL');
legend('RECT','SINCPULSE0','SINCPULSE1','SINCPULSE2');
xlabel('TIME');
ylabel('AMPLITUDE');
t=1;
alpha=0; %Roll Off Factor
for i=time + 10^-8
raisedCosine0(t) = sinc(i/Tsym).*cos(3.14*alpha*i/Tsym)/(1-(2*alpha*i/Tsym).^2);
t=t+1;
end
t=1;
alpha=0.5; %Roll Off Factor
for i=time + 10^-8
% if(i==T || i==-T)
% raisedCosinePulse1(t)=0;
2
% else
raisedCosine1(t) = sinc(i/Tsym).*(cos(3.14*alpha*i/Tsym)/(1-(2*alpha*i/Tsym).^2));
t=t+1;
% end
end
t=1;
alpha=0.7; %Roll Off Factor
for i=time + 10^-8
raisedCosine2(t) = sinc(i/Tsym).*cos(3.14*alpha*i/Tsym)/(1-(2*alpha*i/Tsym).^2);
t=t+1;
end
figure;
plot(time,raisedCosine0,'c','Linewidth',2);hold on;
plot(time,raisedCosine1,'m','Linewidth',2);hold on;
plot(time,raisedCosine2,'k','Linewidth',2);hold on;
title('PULSE SHAPING WITH RAISED COSINE SIGNAL ');
legend('with alpha = 0','with alpha = 0.5','with alpha = 0.7');
xlabel('TIME');
ylabel('AMPLITUDE');
generation of bits
SYMDURATION = ceil(Tsym*Fs);
disp("Bits")
3
Bits
bits = 1×100
1 1 1 1 1 1 1 1 -1 1 1 1 1
disp("Upsampled bits");
Upsampled bits
Linear modulation of the pulse shaping signals with the generated bits by
Convolution
4
figure;
plot(pulshape_Sinc0,'Linewidth',2);
grid on; title('LM with SINC0 PULSE SHAPING');
xlabel('t');
ylabel('Amplitude');
5
figure;
plot(pulshape_Sinc1,'Linewidth',2);
grid on; title('LM with SINC1 PULSE SHAPING');
xlabel('t');
ylabel('Amplitude');
6
figure;
plot(pulshape_Sinc2,'Linewidth',2);
grid on; title('LM with SINC2 PULSE SHAPING');
xlabel('t');
ylabel('Amplitude');
7
figure;
plot(pulshape_RC0,'Linewidth',2);
grid on; title('LM with RAISEDCOSINE0 PULSE SHAPING');
xlabel('t');
ylabel('Amplitude');
8
figure;
plot(pulshape_RC1,'Linewidth',2);
grid on; title('LM with RAISEDCOSINE1 PULSE SHAPING');
xlabel('t');
ylabel('Amplitude');
9
figure;
plot(pulshape_RC2,'Linewidth',2);
grid on; title('LM with RAISEDCOSINE2 PULSE SHAPPING');
xlabel('t');
ylabel('Amplitude');
10
plotting the spectra of pulse shaping signals
Ts=1/Fs;
L=length(sinc0);
df = 1 / (L * Ts);
f = [ -(ceil((L-1)/2):-1:1), 0, (1:floor((L-1)/2)) ] * df;
rectspectrum=(1/L)*fftshift (fft (rect));
sinc0spectrum=(1/L)*fftshift (fft (sinc0));
sinc1spectrum=(1/L)*fftshift (fft (sinc1));
sinc2spectrum=(1/L)*fftshift (fft (sinc2));
L=length(raisedCosine1);
df = 1 / (L * Ts);
f = [ -(ceil((L-1)/2):-1:1), 0, (1:floor((L-1)/2)) ] * df;
f1=f; %% related to the PSD of the LM pulse
RaisedCosine0spectrum=(1/L)*fftshift (fft (raisedCosine0));
RaisedCosine1spectrum=(1/L)*fftshift (fft (raisedCosine1));
RaisedCosine2spectrum=(1/L)*fftshift (fft (raisedCosine2));
figure;
plot(f,abs(rectspectrum),'r','Linewidth',2);hold on;
plot(f,abs(sinc0spectrum),'g','Linewidth',2);hold on;
11
plot(f,abs(sinc1spectrum),'b','Linewidth',2);hold on;
plot(f,abs(sinc2spectrum),'y','Linewidth',2);hold on;
title('SPECTRA OF PULSE SHAPPING SIGNALS');
xlabel('FREQUENCY F in Hz');
ylabel('MAGNITUDE');
legend('RECTPULSE','SINCPULSE0','SINCPULSE1','SINCPULSE2');
figure;
plot(f,abs(RaisedCosine0spectrum),'c','Linewidth',2);hold on;
plot(f,abs(RaisedCosine1spectrum),'m','Linewidth',2);hold on;
plot(f,abs(RaisedCosine2spectrum),'k','Linewidth',2);hold on;
title('SPECTRA OF RAISED COSINE SIGNALS');
xlabel('FREQUENCY F in Hz');
ylabel('MAGNITUDE');
legend('with alpha = 0','with alpha = 0.5','with alpha = 0.7');
12
plotting the spectra of linearly modulated signals
Ts=1/Fs;
M=length(pulshape_Sinc0);
df = 1 / (M * Ts);
f = [ -(ceil((M-1)/2):-1:1), 0, (1:floor((M-1)/2)) ] * df;
rectmodspectrum=(1/M)*fftshift (fft (pulshape_rect));
sinc0modspectrum=(1/M)*fftshift (fft (pulshape_Sinc0));
sinc1modspectrum=(1/M)*fftshift (fft (pulshape_Sinc1));
sinc2modspectrum=(1/M)*fftshift (fft (pulshape_Sinc2));
RC0modspectrum=(1/M)*fftshift (fft (pulshape_RC0));
RC1modspectrum=(1/M)*fftshift (fft (pulshape_RC1));
RC2modspectrum=(1/M)*fftshift (fft (pulshape_RC2));
figure;
plot(f,abs(rectmodspectrum),'r','Linewidth',2);hold on;
title('SPECTRA OF THE LINEARLY MODULATED SIGNALS WITH RECT');
xlabel('FREQUENCY F IN HZ');
ylabel('MAGNITUDE');
13
figure;
plot(f,abs(sinc0modspectrum),'g','Linewidth',2);
title('SPECTRA OF THE LINEARLY MODULATED SIGNALS WITH SINC0');
xlabel('frequency f in Hz');
ylabel('MAGNITUDE');
14
figure;
plot(f,abs(sinc1modspectrum),'b','Linewidth',2);
title('SPECTRA OF THE LINEARLY MODULATED SIGNALS WITH SINC1');
xlabel('FREQUENCY F IN HZ');
ylabel('MAGNITUDE');
15
figure;
plot(f,abs(sinc2modspectrum),'y','Linewidth',2);
title('SPECTRA OF THE LINEARLY MODULATED SIGNALS WITH SINC2');
xlabel('FREQUENCY F IN HZ');
ylabel('MAGNITUDE');
16
QUESTION 3
OBSERVATION
The minimum bandwidth pulse is sinc 2. Here symbol duration is t/4T, therefore bandwidth reduces to
Expansion in time domain leads to compression in frequency domain
figure;
plot(f,abs(RC0modspectrum),'c','Linewidth',2);
title('SPECTRA OF THE LINEARLY MODULATED SIGNALS WITH RAISED COSINE (ALPHA = 0)');
xlabel('FREQUENCY F IN HZ');
ylabel('MAGNITUDE');
17
figure;
plot(f,abs(RC1modspectrum),'m','Linewidth',2);
title('SPECTRA OF THE LINEARLY MODULATED SIGNALS WITH RAISED COSINE (ALPHA = 0.5)');
xlabel('FREQUENCY F IN HZ');
ylabel('MAGNITUDE');
18
figure;
plot(f,abs(RC2modspectrum),'k','Linewidth',2);
title('SPECTRA OF THE LINEARLY MODULATED SIGNALS WITH RAISED COSINE (ALPHA = 0.7)');
xlabel('FREQUENCY F in Hz');
ylabel('MAGNITUDE');
19
QUESTION 4:-
Sampling the recieved signal at kT+ offset & Plotting the Sampled signals
centeridx_sinc0 = 51;
centeridx_sinc1 = 51;
centeridx_sinc2 = 51;
centeridx_rect = 51;
centeridx_RC1 = 51;
centeridx_RC2 = 51;
symdur=Tsym*Fs;
20
peak_RC2 = pulshape_RC2(centeridx_RC2 + offset: symdur:end);
sampled_RC2 = peak_RC2(1:N);
figure;
stem(bits,'b','Linewidth',2);hold on;
stem(sampled_rect,'r','Linewidth',2);hold on;
title('SAMPLED SIGNAL WITH RECT PULSE SHAPING');
xlabel('t');
ylabel('AMPLITUDE');
legend('TXD SYMBOLS', 'RXD SAMPLES');
figure;
stem(bits,'b','Linewidth',2);hold on;
stem(sampledvalues_sinc0,'r','Linewidth',2);hold on;
title('SAMPLED SIGNAL WITH SINC0 PULSE SHAPING');
xlabel('t');
ylabel('AMPLITUDE');
legend('TXD SYMBOLS', 'RXD SAMPLES');
21
figure;
stem(bits,'b','Linewidth',2);hold on;
stem(sampledvalues_sinc1,'r','Linewidth',2);hold on;
title('SAMPLED SIGNAL WITH SINC1 PULSE SHAPING');
xlabel('t');
ylabel('AMPLITUDE');
legend('TXD SYMBOLS', 'RXD SAMPLES');
22
figure;
stem(bits,'b','Linewidth',2);hold on;
stem(sampledvalues_sinc2,'r','Linewidth',2);hold on;
title('SAMPLED SIGNAL WITH SINC2 PULSE SHAPING');
xlabel('t');
ylabel('AMPLITUDE');
legend('TXD SYMBOLS', 'RXD SAMPLES');
23
figure;
stem(bits,'b','Linewidth',2);hold on;
stem(sampled_RC1,'r','Linewidth',2);hold on;
title('SAMPLED SIGNAL WITH (OFFSET = 0) RAISED COSINE(A = 0.5) PULSE SHAPING');
xlabel('t');
ylabel('AMPLITUDE');
legend('TXD SYMBOLS', 'RXD SAMPLES');
24
figure;
stem(bits,'b','Linewidth',2);hold on;
stem(sampled_RC2,'r','Linewidth',2);hold on;
title('SAMPLED SIGNAL WITH (OFFSET = 0) RAISED COSINE(A = 0.7) PULSE SHAPING');
xlabel('t');
ylabel('AMPLITUDE');
legend('TXD SYMBOLS','RXD SAMPLES');
25
OBSERVATIONS:-
It is observed that sinc is not the best pulse to use in practical scenarios where perfect sampling is not possible.
Pulse x(t) is Nyquist at rate 1/T if and only if it satisfies Nyquist criteria for ISI avoidance. The minimum
bandwidth required is 1/T .
p(t) = sinc( t/2T) gives ISI even for zero offset as its value at t = T is non zero
QUESTION 5 :-
t=1;
Inphasecomp= zeros(1,length(time));
Quadraturecomp= zeros(1,length(time));
Passband= zeros(1,length(time));
sinc0 = zeros(1,length(time)); % sinc0 means sinc(t/T)
26
% plotting pulse shaping signals
figure;
plot(time,sinc0,'b','Linewidth',2);hold on;
title('Sinc Pulse0');
xlabel('time');
ylabel('amplitude');
Bits
RealBits = 1×100
1 1 -1 -1 -1 -1 1 -1 1 -1 1 1 1
ImgBits = 1×100
1 -1 1 -1 -1 1 -1 1 1 1 1 -1 1
%disp("Upsampled bits");
RB = upsample(RealBits, symbol_duration);
IB = upsample(ImgBits, symbol_duration);
27
Linear modulation of Inphase and Quadrature Components
Inphasecomp= conv(RB,sinc0); % pulse shaping
Quadraturecomp= conv(IB,sinc0); % pulse shaping
plotting the linearly modulated waveforms in time domain using sinc0 pulse
figure;
plot(Inphasecomp,'r','Linewidth',2);
title('LM OF IN-PHASE COMPONENT WITH SINC0 PULSE SHAPING');
xlabel('t');
ylabel('AMPLITUDE');
figure;
plot(Quadraturecomp,'b','Linewidth',2);
title('LM OF QUADRATURE COMPONENT WITH SINC0 PULSE SHAPING');
xlabel('t');
ylabel('AMPLITUDE');
28
Upconverting from Baseband to Passband
t_up=1:length(Inphasecomp);
inphasecomp_up = 1.414*Inphasecomp.*cos(2*pi*fc*t_up/Fs);
quadcomp_up = -1.414*Quadraturecomp.*sin(2*pi*fc*t_up/Fs);
Passband = inphasecomp_up+quadcomp_up;
29
figure;
plot(quadcomp_up,'b','Linewidth',2);hold on;
title('UP CONVERTED QUADRATURE COMPONENT');
xlabel('t');
ylabel('AMPLITUDE');
legend('UPCONVERTED QUADRATURE')
30
Plotting the Passband signal and Spectra of the Pulse happing Signal
figure;
plot(Passband,'y','Linewidth',2);hold on;
title('PASSBAND SIGNAl');
xlabel('t');
ylabel('AMPLITUDE');
31
%Plotting the spectra of pulse shaping signals
dt=1/Fs;
LN=length(sinc0);
df = 1 / (LN * dt);
f = [ -(ceil((LN-1)/2):-1:1), 0, (1:floor((LN-1)/2)) ] * df;
sinc0spectrum=(1/LN)*fftshift (fft (sinc0));
figure;
plot(f,abs(sinc0spectrum),'b','Linewidth',2);hold on;
title('SPECTRA OF THE PULSE SHAPING SIGNAL');
xlabel('FREQUENCY F in Hz');
ylabel('MAGNITUDE');
32
Downconversion of Passband signal and plotting of the downconverted
passband signal
theta1= pi/6; % given in the question (pi/6,pi/3,pi/2)
theta2= pi/3;
theta3= pi/2;
fpass = 1200;% let
33
figure;
plot(Quadrature_DC,'b','Linewidth',2);hold on;
title('QUADRATURE SIGNAL AFTER DOWNCONVERSION WITH THETA = PI/6');
xlabel('t');
ylabel('AMPLITUDE');
34
Inphase_DC = lowpass(1.414*Passband.*cos(2*pi*fc*t_up/Fs + theta2),fpass,Fs);
Quadrature_DC = lowpass(1.414*Passband.*sin(2*pi*fc*t_up/Fs + theta2),fpass,Fs);
figure;
plot(Inphase_DC,'r','Linewidth',2);hold on;
title('IN-PHASE SIGNAL AFTER DOWNCONVERSION WITH THETA = PI/3');
xlabel('t');
ylabel('AMPLITUDE');
35
figure;
plot(Quadrature_DC,'b','Linewidth',2);hold on;
title('QUADRATURE SIGNAL AFTER DOWNCONVERSION WITH THETA = PI/3');
xlabel('t');
ylabel('AMPLITUDE');
36
Inphase_DC = lowpass(1.414*Passband.*cos(2*pi*fc*t_up/Fs + theta3),fpass,Fs);
Quadrature_DC = lowpass(1.414*Passband.*sin(2*pi*fc*t_up/Fs + theta3),fpass,Fs);
figure;
plot(Inphase_DC,'r','Linewidth',2);hold on;
title('IN-PHASE SIGNAL AFTER DOWNCONVERSION WITH THETA = PI/2');
xlabel('t');
ylabel('Amplitude');
37
figure;
plot(Quadrature_DC,'b','Linewidth',2);hold on;
title('QUADRATURE SIGNAL AFTER DOWNCONVERSION WITH THETA = PI/2');
xlabel('t');
ylabel('AMPLITUDE');
38
Plotting the spectra of Passband signal
dt=1/Fs;
K=length(Passband);
df = 1 / (K * dt);
f = [ -(ceil((K-1)/2):-1:1), 0, (1:floor((K-1)/2)) ] * df;
figure;
plot(f,abs(Passband_spectrum),'m','Linewidth',2);hold on;
39
OBSERVATION
Now instead of b[n] being real, consider that b[n] has both in-phase and quadrature components. Linear
modulation of in-phase and quadrature components with sinc pulse are shown above.
While down conversion, instead of using cos(2πf ct ) and sin(2πf ct ), we use cos(2πf ct + 0) and sin(2πf ct + 0)
is used,
QUESTION 6 :-
40
legend('Linear modulated');
41
OBSERVATION
Power spectral density (PSD) of sinc T/ t and the finite energy finite power linearly modulated waveform are
shown above. it is verified that the PSD of a linearly modulated signal scales as the magnitude
squared of the spectrum of the modulating pulse. So we can conclude that for uncorrelated symbols the shape
QUESTION 7:-
Calculating and plotting Power spectral density for Bits Sequence without
any Randomness
symbol_duration = ceil(Tsym*Fs);
disp("Bits")
Bits
Upsampled bits
b = upsample(bits, symbol_duration);
42
%% Linear modulation
pul_shape_Sinc0 = conv(b,sinc0); % pulse shaping
43
ylabel('MAGNITUDE');
figure;
plot(f1,Psf,'r','Linewidth',2);hold on;
title('POWER SPECTRAL DENSITY OF SINC0');
xlabel('frequency f in Hz');
ylabel('MAGNITUDE');
44
figure;
plot(f,Ssf,'b','Linewidth',2);hold on;
title('POWER SPECTRAL DENSITY OF LINEAR MODULATED SIGNAL W/O RANDOMNESS FOR N = 10000')
xlabel('frequency f in Hz');
ylabel('MAGNITUDE');
45
OBSERVATION
Power spectral density (PSD) of the finite energy finite power linearly modulated waveform without randomness
is shown above. The time average of the PSD is not same as the PSD we found before with a random
sequence.
Here, with b[n] as a sequence of all ones, we obtained a delta function as the PSD i.e. the amplitude of DC
component is more than other frequencies in the linearly modulated waveform
46