Question

In: Advanced Math

Use the Matlab code discussed in class to build a simulator for the digital modulation scheme...

Use the Matlab code discussed in class to build a simulator for the digital modulation scheme PPM Coherent. Once finished, run the simulations required to plot BER curves with a minimum probability of bit-error of 10.

1. Plots:

a. ??? vs ??? (??) plot – in the same graph, plot at least 4 BER curves corresponding to different values of symbol periods and pulse widths.

b. Transmitted signal plot – plot the transmitted signal corresponding to 3 bits.

c. Received signal plots – for the transmitted signal (3 bits), plot the received noisy signal for at least 4 values of ??? (e.g. 0 ??, 10 ??, 20 ??, 30 ??) .

Code in Matlab:

% Description: Simple simulator for digital (binary) communications

%% Main Function
function runComm_code()
clear;clc;
  
SNRdB = 0:0.5:26;
nBits = 1e6;
SNRdBLength = length(SNRdB);
Pe = ones(1,SNRdBLength);
clc; disp('Simulation running: 0.0% completed.');
for i = 1:SNRdBLength
Pe(i) = transmitReceive(nBits,SNRdB(i));
clc;fprintf('%s: %.1f%% completed','Simulation running',i/SNRdBLength*100);
end
hold on; semilogy(SNRdB,Pe); grid on;
clc; disp('Simulation finished.');
return

%% Bit Transmission Function
function [Perror,nErrors,TxBits,RxBits] = transmitReceive(nBits,SNRdB)
% TxBits = [0 1 1 0 1 0 0 1 1 1];
nBitsMax = 100000;
nBitsOrig = nBits;
TxBits = [];
RxBits =[];
if(nBits > nBitsMax)
n = ceil(nBits/nBitsMax);
nErrorsArr = zeros(1,n);
for i = 1:n
if(nBits < nBitsMax)
[~,nErrorsArr(i),TxBitsTmp,RxBitsTmp] = transmitReceive(nBits,SNRdB);
TxBits = [TxBits,TxBitsTmp];
RxBits = [RxBits,RxBitsTmp];
break;
else
[~,nErrorsArr(i),TxBitsTmp,RxBitsTmp] = transmitReceive(nBitsMax,SNRdB);
TxBits = [TxBits,TxBitsTmp];
RxBits = [RxBits,RxBitsTmp];
nBits = nBits - nBitsMax;
end
end
nErrors = sum(nErrorsArr);
Perror = nErrors/nBitsOrig;
return;
end
  
TxBits = round(rand(1,nBits));
TxSignals = modulation(TxBits);
[RxSignals] = addAWGNoise(TxSignals,SNRdB);
RxBits = demodulation(RxSignals);
errorBits = TxBits ~= RxBits;
nErrors = sum(errorBits);
Perror = nErrors/nBits;
  

return

%% Modulation and Demodulation Functions
function [outSignals,time] = modulation(inBits)

% This code is for On-Off Keying (OOK) modulation
% You need to substitute this with your own Matlab code according
% to your assigned modulation scheme.

pulseWidth = 1e-9;
timeWindow = 10.5e-9;
carrierFreq = 4e9;
  
signalBW = 1.5/pulseWidth;
osFactor = 1 + carrierFreq/signalBW;
  
[signal1,time] = pulseSignal(pulseWidth,timeWindow,osFactor);
signal1 = signal1.*squareSignal(time,carrierFreq);
signalLength = length(signal1);
signal0 = zeros(signalLength,1);
  
inBits = inBits(:)';
nBits = length(inBits);
outSignals = zeros(signalLength,nBits);
col0 = inBits == 0;
col1 = inBits == 1;
outSignals(:,col0) = repmat(signal0,1,sum(col0));
outSignals(:,col1) = repmat(signal1,1,sum(col1));

return
function [outBits] = demodulation(inSignals)
  
% This code is for On-Off Keying (OOK) modulation
% You need to substitute this with your own Matlab code according
% to your assigned modulation scheme.

SNRmin = 10^(12/10);
Ps = sum(modulation(1).^2);
Po = Ps./SNRmin;
  
Psignals = sum(inSignals.^2);
outBits = Psignals > Po;
return

%% Noise Adding Function
function [outSignals,noiseSignals] = addAWGNoise(signals,SNRdB)
signalsSize = size(signals);
SNR = 10^(SNRdB/10);
Ps = max(sum(signals.^2));
Po = Ps./SNR;
noiseSignals = sqrt(Po/2).*randn(signalsSize(1),signalsSize(2));
outSignals = signals+noiseSignals;
return

%% Signal Creation Functions
function [outSignal,time] = pulseSignal(Tp,Tw,osFactor)
if(nargin == 2), osFactor = 1; end
if(osFactor < 1), osFactor = 1; end
B = 1.5/Tp;
fs = osFactor*2*B;
Nw = ceil(fs*Tw);
Np = ceil(fs*Tp);
outSignal = [0; ones(Np,1); zeros(Nw-Np-1,1)];
outSignal(end)=0;
time = (0:length(outSignal)-1)'/fs;
return
function [outSignal] = squareSignal(time,freq)
tsample = time(2)-time(1);
tperiod = 1/freq;
n = ceil(tperiod/tsample);
npos = ceil(n/2);
nneg = n - npos;
Nperiods = ceil(time(end)*freq);
signalTmp = [ones(npos,1); -1*ones(nneg,1)];
outSignal = repmat(signalTmp,Nperiods+1,1);
outSignal = [ 0; outSignal(1:length(time)-1) ];
return

Solutions

Expert Solution

IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE TO HELP YOU ALL THE BEST.

Answer:

Explanation:

CODE:

Answer for 1-a

clc;          //it clears the data

clear all; //clears all the pervious data

close all; //closes all the pervious data

b=101;    //bit rate

data=randint(1,b);%random bit generation (1 or 0)

s=2*data-1

SNRdB=0:9;         //signal to noise ratio I db

SNR=10.^(SNRdB/10);

for(k=1:length(SNRdB))

y=s+awgn(s,SNRdB(k));      //y signal representation

error=0;

for(c=1:1:b)

    if (y(c)>0&&data(c)==0)||(y(c)<0&&data(c)==1)

        error=error+1;               //increment the error value

    end

end

error=error/b; %Calculate error/bit

m(k)=error;            //mk signal wil end here

end

figure(1)

semilogy(SNRdB,m,'r','linewidth',2),grid on,hold on;

BER_th=(1/2)*erfc(sqrt(SNR));          //square of the bit rate

semilogy(SNRdB,BER_th,'k','linewidth',2);

title(' curve for Bit Error Rate verses SNR for Binary PSK modulation');

xlabel(' SNR(dB)');

ylabel('BER');        //y labei reperesentation

legend('simulation','theorytical')

Answr for 1-b:

clear all; //clears all the pervious data

close all; closes all the pervious data

T=1;     /t value representation

b=[1 0 1];        //bit rate

NRZ_out=[];

Vp=1;

for index=1:size(b,2)

if b(index)==1

NRZ_out=[NRZ_out ones(1,200)*Vp]; //non return zero value

elseif b(index)==0

NRZ_out=[NRZ_out ones(1,200)*(-Vp)];

end

end//some the prog end herev

figure(1);

stem(b);

xlabel('Time (seconds)-->')

ylabel('Amplitude (volts)-->')

title('Impulses of bits to be transmitted');

figure(2);

plot(NRZ_out);//ploting th nrz plot

xlabel('Time (seconds)-->');

ylabel('Amplitude (volts)-->');

title('Generated NRZ signal');

t=0.005:0.005:5;

f=5;

s=NRZ_out.*(sqrt(2/T)*cos(2*pi*f*t));

figure;

plot(s);

xlabel('Time (seconds)-->');

ylabel('Amplitude (volts)-->');

title('BPSK Modulated signal'); //representing of the title

answer for 1- c

y=[];

demodulated=Modulated.*(sqrt(2/T)*cos(2*pi*f*t));

for i=1:200:size(demodulated,2)

y=[y trapz(t(i:i+199),demodulated(i:i+199))];

end

received=y>0;

figure;

stem(received)

title('Impulses of Received bits');

xlabel('Time (seconds)-->');     //xlabel representation

ylabel('Amplitude (volts)')

Eb_N0_dB = 0 ;

Eb_N0=10^(Eb_N0_dB/10);

M=2;//representing the m-value

fs=1000;

T=1;

Ts=T/log2(M); //ts value

R=1/Ts;

A=5;

E=A^2*T;

ts=1/fs;

t=0:ts:1

noiseVariance=E*fs/(2*log2(M)*Eb_N0);

sigma_n=sqrt(noiseVariance);

n = sigma_n*randn(1,length(s));

r = s+n ;% received noisy signal array

subplot(4,1,4);

plot(t,r);           //plot the t,r signals

axis([0 MaxPlotTime min(r) max(r)]);

grid on;//it will terminate here

xlabel('time');

ylabel('r(t)');

title('Received Bandpass BPSK signal r(t)'); //representing the title

PLS ..RATE THUMBSUP IT HELPS ME ALOT

THANKS GOODLUCK

THANK YOU....!


Related Solutions

Use the Matlab code discussed in class to build a simulator for the digital modulation scheme...
Use the Matlab code discussed in class to build a simulator for the digital modulation scheme PPM Coherent. Once finished, run the simulations required to plot BER curves with a minimum probability of bit-error of 10. 1. Plots: a. ??? vs ??? (??) plot – in the same graph, plot at least 4 BER curves corresponding to different values of symbol periods and pulse widths. b. Transmitted signal plot – plot the transmitted signal corresponding to 3 bits. c. Received...
) Suppose A,B are using the majority error-correcting code scheme F discussed in class. To review,...
) Suppose A,B are using the majority error-correcting code scheme F discussed in class. To review, if M is the plaintext bit-string A wants to get to B, A calculates F(M) to be the bit-string consisting of every bit of M repeated thrice. So, for example, if M = 011, F(M) will be 000111111. The idea is that F(M) is transmitted, and if there is a single bit error (so that a 1 gets switched to a 0 or a...
pls, I need Matlab code for, OFDM modulation (Matlab demo by at least 4 carriers)
pls, I need Matlab code for, OFDM modulation (Matlab demo by at least 4 carriers)
I need a matlab code for my presentation. Code should include Single Sideband Amplitude Modulation and...
I need a matlab code for my presentation. Code should include Single Sideband Amplitude Modulation and Demodulation. It should figure 3 things: -time domain of given message signal in Amplitude Modulation and Single Sideband Amplitude Modulation -frequency domain of given signal in Amplitude Modulation and Single Sideband Amplitude Modulation -And it should demodulate and show message signal.
Write a Matlab code for PSK modulation of Polar signal full widht rectangular pulses and data...
Write a Matlab code for PSK modulation of Polar signal full widht rectangular pulses and data rate 1 mbit/s also find PSD of psk and estimate Bandwidth
Use the DC Construction kit (the PHET simulator) to build a simple circuit to perform the...
Use the DC Construction kit (the PHET simulator) to build a simple circuit to perform the following task: You are asked to use a single resistor and a 110 V DC battery for the purpose of boiling a liter of water (4,184 Joule/Kg*degree Celsius), with a staring temperature of 20 C, in exactly 4 minutes.
Simulate this code in ISE Simulator (ISim) and screenshot the simulation library IEEE; use IEEE.STD_LOGIC_1164.ALL; use...
Simulate this code in ISE Simulator (ISim) and screenshot the simulation library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity multiplexer is Port (     din:in STD_LOGIC_VECTOR (7 downto 0);    sel:in STD_LOGIC_VECTOR (2 downto 0);    dout : out STD_LOGIC); end multiplexer; architecture Behavioral of multiplexer is begin     process (din,sel)     begin       case sel is            when "000"=> dout <= din(7);            when "001"=> dout <= din(6);            when "010"=> dout <= din(5);            when "011"=>...
Use the Simulator (Core) and the attached skeleton class (MyPrettySimulator), and extend the framework with the following functions:
Use the Simulator (Core) and the attached skeleton class (MyPrettySimulator), and extend the framework with the following functions:HalfAdder(x,y)FullAdder(x,y,c_i)Switches.
I need matlab code for digital watermarking using SVD. Please explain each step
I need matlab code for digital watermarking using SVD. Please explain each step
this is my matlab code for class, my professor commented "why is the eps an input...
this is my matlab code for class, my professor commented "why is the eps an input when it is set inside the function and not specified as a variable? how do i fix? function[] = () %Declare Global Variables global KS; global KC; KC = 0; KS = 0; End = 0; while (End == 0) choice = questdlg('Choose a function', ... 'Fuction Menu', ... 'A','B','B'); switch choice; case 'A' Program = 'Start'; while strcmp(Program,'Start'); Choice = menu('Enter the Trigonometric...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT