

Digital Communication Projects using Matlab.
1. Multiple Input Multiple Output(MIMO) using Matlab
clc;
close all;
clear all;
mT = 2; % No.of transmitters
mR = 2; % No.of receivers
ITER = 1000; % number of iterations.
SNRdB = [0:25]; % SNR maximum scale
SNR = 10.^(SNRdB/10); % SNR in decibels
C_SISO = zeros(1,length(SNR));
C_SIMO = zeros(1,length(SNR));
C_MISO = zeros(1,length(SNR));
C_MIMO = zeros(1,length(SNR));
for ite = 1:ITER
h_SISO = (randn +1i*randn)/sqrt(2);
h_SIMO = (randn(mR,1)+1i*randn(mR,1))/sqrt(2);
h_MISO = (randn(1,mT)+1i*randn(1,mT))/sqrt(2);
h_MIMO = (randn(mR,mT)+1i*randn(mR,mT))/sqrt(2);
for K = 1:length(SNR)
C_SISO(K) = C_SISO(K) + log2(1+ SNR(K)*norm(h_SISO)^2);
C_SIMO(K) = C_SIMO(K) + log2(1+ SNR(K)*norm(h_SIMO)^2);
C_MISO(K) = C_MISO(K) + log2(1+ SNR(K)*norm(h_MISO)^2/mT);
C_MIMO(K) = C_MIMO(K) + log2(abs(det(eye(mR)+SNR(K)*h_MIMO*h_MIMO'/mT)));
end
end
C_SISO = C_SISO/ITER;
C_SIMO = C_SIMO/ITER;
C_MISO = C_MISO/ITER;
C_MIMO = C_MIMO/ITER;
plot(SNRdB,C_SISO,'r',SNRdB,C_SIMO,'b',SNRdB,C_MISO,'m',SNRdB,C_MIMO,'k')
%legend('SISO','SIMO','MISO','MIMO')
xlabel('SNR in dB')
ylabel('Capacity (b/s/Hz)')
title('Capacity Vs. SNR')
grid;
Output

2. Pulse Width Modulation(PWM) working Principal using Matlab
clc;
clear all;
close all;
F2=input('Messsage frequency=');
F1=input('Carrie Sawtooth Frequency=');
A=5;
t=0:0.001:1;
c=A.*sawtooth(2*pi*F1*t);
subplot(3,1,1)
plot(t,c);
xlabel('time')
ylabel('Amplitude');
title('Carrier Sawtooth Wave');
grid on;
m=0.75*A.*sin(2*pi*F2*t);
subplot(3,1,2);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;
n=length(c);
for i=1:n
if (m(i)>=c(i))
pwm(i)=1;
else
pwm(i)=0;
end
end
subplot(3,1,3);
plot(t,pwm);
xlabel('Time');
ylabel('Amplitude');
title('plot of PWM');
axis([0 1 0 2]);
grid on;
Output

3. Quadrature Amplitude Modulation(QAM)
Fd=1;Fs=1;
nsamp=1;
M=32;
k = log2(M);
n = 30000;
x = randi([0 1],n,1);
stem(x(1:40),'filled');
title('Random Bits');
xlabel('Bit Index');
ylabel('Binary Value');
xsym = bi2de(reshape(x,k,length(x)/k).');
figure;
stem(xsym(1:10));
title('Random Symbols');
xlabel('Symbol Index');
ylabel('Integer Value');
y=qammod(xsym,M);
title('modulated');
xlabel('Symbol Index');
ylabel('Integer Value');
ytx = y;
stem(y(1:10));
EbNo=10;
snr = EbNo + 10*log10(k) - 10*log10(nsamp);
pinput=std(ytx);
noise = (randn(1,n/k)+sqrt(-1)*randn(1,n/k))*(1/sqrt(2));
Noisestd = (pinput*10^(-snr/20));
ynoisy = ytx + (Noisestd*noise);
yrx=ynoisy;
figure;
plot(real(yrx(1:5e3)),imag(yrx(1:5e3)),'b*');
hold on;
plot(real(ytx(1:5e3)),imag(ytx(1:5e3)),'y.');
title('Signal Constellation');
legend('Received Signal', 'Transmitted Signal');
axis([-5 5 -5 5]);
hold off;
Output

4. MATLAB code for Binary Frequency Shift Keying(BFSK) Modulation and Demodulation
clc;
clear all;
N=8;
b=round(rand(1,N));
subplot(4,1,1);
stem(b,'filled')
xlabel('Bits index')
ylabel('transmitted bits')
NRZ_out=[];
Vp=1;
for index=1:size(b,2)
if b(index)==1
NRZ_out=[NRZ_out ones(1,200)*Vp];
elseif b(index)==0
NRZ_out=[NRZ_out zeros(1,200)*(-Vp)];
end
end
subplot(4,1,2);
plot(NRZ_out)
t=0.005:0.005:8;
f2=3;
f1=5;
A=5;
mod_sig=[];
for(i=1:1:length(NRZ_out))
if(NRZ_out(i)==1)
y=A*cos(2*pi*f1*t(i));
else
y=A*cos(2*pi*f2*t(i));
end
mod_sig=[mod_sig y];
end
subplot(4,1,3);
plot(t,mod_sig)
xlabel('Time in seconds')
ylabel('Modulated signal')
demod_branch_1=mod_sig.*(cos(2*pi*f1*t));
demod_branch_2=mod_sig.*(cos(2*pi*f2*t));
y_1=[];
for i=1:200:size(demod_branch_1,2)
y_1=[y_1 trapz(t(i:i+199),demod_branch_1(i:i+199))];
end
y_2=[];
for i=1:200:size(demod_branch_2,2)
y_2=[y_2 trapz(t(i:i+199),demod_branch_2(i:i+199))];
end
rec_sig=y_1>y_2;
subplot(4,1,4);
stem(rec_sig,'filled','r')
xlabel('Bits index')
ylabel('Received bits')
Output

5. Pulse Code Modulation (PCM)
P=5;
t = [0:0.1:1*pi];
sig = 4*sin(t);
Vh=max(sig);
V1=min(sig);
N=3;M=2^N;
S=(Vh-V1)/M;
partition = [V1+S:S:Vh-S];
codebook = [V1+S/2:S:Vh-S/2];
[index,quantized_sig,distor] = quantiz(sig,partition,codebook);
codedsig=de2bi(index,'left-msb');
codedsig=codedsig;
txbits=codedsig(:);
errvec=randsrc(length(txbits),1,[0 1;(1-P/100) P/100]);
rxbits=rem(txbits+errvec,2);
rxbits=reshape(rxbits,N,length(sig));
rxbits=rxbits';
index1=bi2de(rxbits,'left-msb');
reconstructedsig=codebook(index1+1);
figure,
subplot(2,2,1);
stem(t,sig);
xlabel('Time');
title('original signal');
subplot(2,2,2);
stem(t,quantized_sig);
xlabel('time)');
title('quantized signal');
tt=[0:N*length(t)-1];
subplot(2,2,3);
stairs(tt,txbits);
xlabel('time');
title('PCM Waveform');
subplot(2,2,4);
stem(t,reconstructedsig);
xlabel('time');
title('received signal');

6. Quadrature Phase Shift Keying (QPSK), Matlab Code
clc;
clear al;
close all;
Tb=1;
t=0:(Tb/100):Tb;
fc=1;
c1=sqrt(2/Tb)*cos(2*pi*fc*t);
c2=sqrt(2/Tb)*sin(2*pi*fc*t);
subplot(3,2,1);
plot(t,c1);
title('Carrier Signal-1');
xlabel('t ----->');
ylabel('c1(t)');
grid on;
subplot(3,2,2);
plot(t,c2);
title('Carrier Signal-2');
xlabel('t ----->');
ylabel('c2(t)');
grid on;
N=16;
m=rand(1,N);
t1=0;
t2=Tb;
for i=1:2:(N-1)
t=[t1:(Tb/100):t2];
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
else
m(i)=0;
m_s=-1*ones(1,length(t));
end
odd_sig(i,:)=c1.*m_s;
if m(i+1)>0.5
m(i+1)=1;
m_s=ones(1,length(t));
else
m(i+1)=0;
m_s=-1*ones(1,length(t));
end
even_sig(i,:)=c2.*m_s;
Qpsk =odd_sig + even_sig;
subplot(3,2,3);
stem(m);
title('Binary Data of Message Signal');
xlabel('n ----->');
ylabel('b(n)');
grid on;
subplot(3,2,4);
plot(t,Qpsk(i,:));
title('QPSK Modulated Signal');
xlabel('t ------>');
ylabel('s(t)');
grid on;
hold on;
t1=t1+(Tb+0.01);
t2=t2+(Tb+0.01);
end
hold off;
t1=0;
t2=Tb;
for i=1:N-1
t=[t1:(Tb/100):t2];
x1=sum(c1.*Qpsk(i,:));
x2=sum(c2.*Qpsk(i,:));
if (x1>0 && x2>0)
demod(i)=1;
demod(i+1)=1;
elseif (x1>0 && x2<0)
demod(i)=1;
demod(i+1)=0;
elseif (x1<0 && x2<0)
demod(i)=0;
demod(i+1)=0;
elseif (x1<0 && x2>0)
demod(i)=0;
demod(i+1)=1;
end
end
subplot(3,2,5);
stem(demod);
title('QPSK Demodulated Signal');
xlabel('n ------>');
ylabel('b(n)');
grid on;
Output

7. Differential Phase Shift Keying (DPSK), Matlab code
clc;
clear al;
close all;
N=10;
bk=round(rand(1,N));
br=10^6;
f=br;
T=1/br;
grid on;
subplot(4,1,1);
stem(bk,'linewidth',1.5);
title('INFORMATION BITS TO BE TRANSMITTED');
axis([0 11 0 1.5]);
dk=1;
coded =[dk];
for i=1:length(bk)
temp=~xor(dk,bk(i));
coded=[coded temp];
dk=temp;
end
subplot(4,1,2);
stem(coded,'linewidth',1.5);
grid on;
title('Differentially encoded signal');
axis([0 11 0 1.5]);
coded_PNRZ=2*coded-1;
mod_sig=[];
t=T/99:T/99:T;
for i=1:length(coded)
temp=coded_PNRZ(i)*sqrt(2/T)*cos(2*pi*f*t);
mod_sig=[mod_sig temp];
end
subplot(4,1,3);
tt=T/99:T/99:(T*length(coded));
plot(tt,mod_sig,'linewidth',1.5);
title('dpsk modulation signal');
grid on;
rec_sig=mod_sig;
rec_data=[];
for i=1:length(coded)-1
y_in=rec_sig((i-1)*length(t)+1:i*length(t)).*rec_sig((i)*length(t)+1:(i+1)*length(t));
y_in_intg=trapz(t,y_in);
if (y_in_intg>0)
temp=1;
else
temp=0;
end
rec_data=[rec_data temp];
end
subplot(4,1,4);
stem(rec_data,'linewidth',3);
title('received information bits');
axis([0 11 0 1.5]);

8. BPSK(Binary Phase Shift Keying) Matlab Project code
clc;
clear all;
close all;
%fine Transmitted Signal=
N=10;
x_inp=round(rand(1,N)); % Message Signal
Tb=0.0001; % Bit Period
%Represent Input Signal as Digital Signal
x_bit=[];
nb=100;
for n=1:1:N
if x_inp(n)==1
x_bitt=ones(1,nb);
else
x_bitt=zeros(1,nb);
end
x_bit=[x_bit x_bitt];
end
t1=Tb/nb:Tb/nb:nb*N*(Tb/nb);
f1=figure(1);
set(f1,'color',[1 1 1]);
subplot(3,1,1);
plot(t1,x_bit,'LineWidth',2);
grid on;
axis([0 Tb*N -0.5 1.5]);
ylabel('Amplitude(volt)');
xlabel('Time(sec)');
title('Input Signal as Digital Signal');
%fine BPSK Modulation
Ac=10;
mc=4;
fc=mc*(1/Tb);
fi1=0;
fi2=pi;
t2=Tb/nb:Tb/nb:Tb;
t2L=length(t2);
x_mod=[];
for i=1:1:N
if x_inp(i)==1
x_mod0=Ac*cos(2*pi*fc*t2+fi1);
else
x_mod0=Ac*cos(2*pi*fc*t2+fi2);
end
x_mod=[x_mod x_mod0];
end
t3=Tb/nb:Tb/nb:Tb*N;
subplot(3,1,2);
plot(t3,x_mod);
xlabel('Time(sec)');
ylabel('Amplitude(volt)');
title('Signal of BPSK modulation');
%Transmitted Signal x
x=x_mod;
h=1;
w=0;
%Received Signal
y=h.*x+w;
%BPSK Demodulation
y_dem=[];
for n=t2L:t2L:length(y)
t=Tb/nb:Tb/nb:Tb;
c=cos(2*pi*fc*t);
y_dem0=c.*y((n-(t2L-1)):n);
t4=Tb/nb:Tb/nb:Tb;
z=trapz(t4,y_dem0);
A_dem=round((2*z/Tb));
if(A_dem>Ac/2)
A=1;
else
A=0;
end
y_dem=[y_dem A];
end
x_out=y_dem;
%Represent output signal as Digital Signal
xx_bit=[];
for n=1:length(x_out)
if x_out(n)==1
xx_bitt=ones(1,nb);
else
xx_bitt=zeros(1,nb);
end
xx_bit=[xx_bit xx_bitt];
end
t4=Tb/nb:Tb/nb:nb*length(x_out)*(Tb/nb);
subplot(3,1,3)
plot(t4,xx_bit,'LineWidth',2);
grid on;
axis([0 Tb*length(x_out) -0.5 1.5]);
ylabel('Amplitude(volt)');
xlabel('Time(sec)');
title('Output Signal as Digital Signal');
Output

Join us for Regular Updates
Telegram | Join Now |
Join Now | |
Join Now | |
Join Now | |
Join Now | |
Join our Telegram | connectkreations |
More Posts
- For Placement Preparation. Placement Cell
- FOR MORE COURSES. FREE COURSES
- FOR Job Updates. JOB AND INTERNSHIP UPADTES
- For Latest Trends in Technology. Technology Blog
- For Quotes and Poems. Quotes-Poems
About Connect Kreations
We the team Connect Kreations have started a Blog page which is eminently beneficial to all the students those who are seeking jobs and are eager to develop themselves in a related area. As the world is quick on uptake, our website also focuses on latest trends in recent technologies. We are continuously putting our efforts to provide you with accurate, best quality, and genuine information. Here we also have complete set of details on how to prepare aptitude, interview and more of such placement/ off campus placement preparation.
Connect Kreations is excited to announce the expansion of our services into the realm of content creation! We are now offering a wide range of creative writing services, including poetry, articles, and stories.
Whether you need a heartfelt poem for a special occasion, a thought-provoking article for your blog or website, or an engaging story to captivate your audience, our team of talented writers is here to help. We have a passion for language and a commitment to creating high-quality content that is both original and engaging.
Our services are perfect for individuals, businesses, and organizations looking to add a touch of creativity and personality to their content. We are confident that our unique perspectives and diverse backgrounds will bring a fresh and exciting voice to your project.
Thank you for choosing Connect Kreations for your content creation needs. We look forward to working with you and helping you to bring your vision to life!
The website is open to all and we want all of you to make the best use of this opportunity and get benefit from it..🤓
- Our Websites: Connect Kreations