Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB function who takes as input parameters: ibs: A vector which repre

ID: 2248902 • Letter: W

Question

Write a MATLAB function who takes as input parameters:

ibs: A vector which represents input bit stream

tlc: Type of line code: A character variable which can take following values: NRZ-L (for NRZ-LEVEL),NRZ-M (for NRZ-MARK), NRZ-S (for NRZ-SPACE), __AMI (for BIPOLAR (AMI)), RZ, bi_RZ (for BIPOLAR RZ), manch (for MANCHESTER (BIPHASE)), and d_man (for DIFF. MANCHESTER)

Rb: A scalar which shows input bit rate Also, write a function to plot the generated waveform.

Procedure One can generate the functions lc_gen(ibs,tlc,Rb) and lc_plot(x,Rb) with parameters as defined above.

As an example: b=[0 0 1 1 1 0 0 1 1 1 1 0];

x=lc_gen(b,’__AMI’,2);

lc_plot(x,2) will generate following waveform (note that each second contains two pulses for Rb = 2):

Explanation / Answer

Sorry due to shortage of time I have not done all 8 line codings as asked in question but done for 4 code generation.

% Que-01: Script File for accepting the inputs
clc
clear all
close all

% Input the Bit Stream whose Line code is to form
ibs=input('Enter the bit stream whose Line code is to found out: ');

% Input the Type of coding to be done
fprintf('List to choose the Line Coding Technique ');
fprintf('1.NRZ-L 2.NRZ-M 3.NRZ-S 4.AMI 5.RZ 6.bi_RZ 7.manch 8.Differential Manchester');
tlc=input('Enter the relevant number from the list for choosing the line-coding technique');

% Input Bit Rate
Rb=input('Enter the input bitrate');

% Function Call for Line Code Generation
x=lc_gen(ibs,tlc,Rb);

% Function call for ploting the Line Code
lc_plot(x,Rb)

% Que-2: Function for generation of line code

function [x]=lc_gen(ibs,tlc,Rb)
% This function generates the Line Code as per the input parameters
% Value of tlc as
% 1.unipolar
% 2.polar_code
% 3.bipolar_code
% 4.manchester_code
%
% ibs= input bit sream whose line code is to be found
% Rb= input bit rate

nx=size(ibs,2);
sign=1;
i=1;
while i<nx+1
t = i:0.001:i+1-0.001;
  
if tlc==1 % unipolar_code
if ibs(i)==1
code=square(t*2*pi,100);
else
code=0;
end
end
  
if tlc==2 % polar_code
if ibs(i)==1
code=square(t*2*pi,100);
else
code=-square(t*2*pi,100);
end
end
  
if tlc==3 % bipolar_code
if ibs(i)==1
code=sign*square(t*2*pi,100);
sign=sign*-1;
else
code=0;
end
end
  
if tlc==4 % manchester_code
if ibs(i)==1
code=-square(t*2*pi,50);
else
code=square(t*2*pi,50);
end
end
  
x=[x,code];
i=i+1;
end

% Que-3: Function for plotting

function []=lc_plot(x,Rb)
l=size(x,2);
i=1;
while i<nx+1
t = i:0.001:i+1-0.001;
plot(t,x(t));
hold on;
grid on;
axis([1 10 -2 2]);
i=i+1;
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote