x=[1 0 1 1 0 1];
nx=size(x,2);
sign=1;
i=1;
while i<nx+1
t = i:0.001:i+1-0.001;
if x(i)==1
unipolar_code=square(t*2*pi,100);
polar_code=square(t*2*pi,100);
bipolar_code=sign*square(t*2*pi,100);
sign=sign*-1;
manchester_code=-square(t*2*pi,50);
else
unipolar_code=0;
polar_code=-square(t*2*pi,100);
bipolar_code=0;
manchester_code=square(t*2*pi,50);
end
subplot(4,1,1);
plot(t,unipolar_code);
ylabel('unipolar code');
hold on;
grid on;
axis([1 10 -2 2]);
subplot(4,1,2);
plot(t,polar_code);
ylabel('polar code');
hold on;
grid on;
axis([1 10 -2 2]);
subplot(4,1,3);
plot(t,bipolar_code);
ylabel('bipolar code');
hold on;
grid on;
axis([1 10 -2 2]);
subplot(4,1,4);
plot(t,manchester_code);
ylabel('manchester code');
hold on;
grid on;
axis([1 10 -2 2]);
i=i+1;
end
suhaag_shakya at 10:38 PM
Share
10 comments:
Tien NguyenNovember 18, 2013 at 8:09 AM
Can you write to me a full code of HDB3?
thanks.
Reply
Replies
suhaag_shakyaFebruary 23, 2014 at 7:10 AM
https://www.blogger.com/blogger.g?blogID=1098589623302643586#editor/target=post;postID=3255457773256582234;onPublishedMenu=posts;onClosedMenu=posts;postNum=0;src=postname
Reply
AutomatistFebruary 5, 2014 at 11:03 AM
hi! the code you have written above, is applicable the way it is on matlab?
Reply
grujash ardeshanaApril 16, 2014 at 7:23 AM
thanks dude
Reply
孤狼August 30, 2014 at 2:32 AM
but why some of the line is missing or breaking?
anyway to solve it?
Reply
Rishabh c nOctober 7, 2014 at 12:27 PM
Create a MATLAB program for the B8ZS code. Create signaling formats corresponding to 1,000,000 bits making the following assumptions on your bitstream (the following are separate cases to consider)
o P(1)=P(0)=0.5, i.e. ‘1’ and ‘0’ are equally likely
o P(1)=0.3; P(0)=0.7
Reply
pramodh bayyanaNovember 9, 2016 at 5:16 AM
do u have code for rz polar and bipolar
Reply
Replies
Sameer HadiNovember 29, 2016 at 11:20 PM
if x(i)==1
unipolar_code=square(t*2*pi,100);
polar_code=square(t*2*pi,100);
bipolar_code=sign*square(t*2*pi,100);
sign=sign*-1;
manchester_code=-square(t*2*pi,50);
else
unipolar_code=0;
polar_code=-square(t*2*pi,100);
bipolar_code=0;
manchester_code=square(t*2*pi,50);
EmoticonEmoticon