In this article I will start with the basics of MATLAB for
writing scripts.I have written this MATLAB scripts for simulating the working
of Digital Communication line trainer of Line Coding type Unipolar RZ.I will
not delve into detail about the line coding technique as it is pretty basic.
As you can see from the screenshot I have set the input data
as 11110000 and we can see the corresponding output.
Let us see the data line by line
Let It is required to
clear the console area and clear all the variables that were being used in
MATLAB Command area.So to achieve that we use these commands.
close
all;
This command closes all
the active windows previously running.
clc;
clear
all;
close
all;
It is required to clear
the console area and clear all the variables that were being used in MATLAB
Command area. So, to
achieve that we use these commands.
Now we will define a line matrix variable bits of 8-bit length, this is the data
variable for showing the input data.You can see the
bits
= [1 1 1 1 0 0 0 0 0];
bitrate
= 1; % bits per second
Now we will call the urz function of matlab for variable bits of 8-bit length,the output of this function is used for plotting the output
I have attached the code for your reference I hope this helps.Soon I will add more line coding techniques.
Source
Code(Contents of unipolar.m)
clc;
clear
all;
close
all;
%bits=input('Enter
bit sequence of 9-bit width : ');
bits
= [1 1 1 1 0 0 0 0 0];
bitrate
= 1; % bits per second
figure;
subplot(4,1,2);
[t,s]
= urz(bits,bitrate);
plot(t,s,'LineWidth',3);
axis([0
t(end) -0.1 1.1])
grid
on;
hold
on;
title(['Unipolar RZ: ['
num2str(bits) ']']);