Pages

Friday, December 21, 2012

matlab code for line coding : unipolar, polar, bipolar and manchester code

%Matlab code to generate line code wave form  for given bit stream

clc;
close all;
clear all;
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

14 comments:

  1. Can you write to me a full code of HDB3?
    thanks.

    ReplyDelete
    Replies
    1. https://www.blogger.com/blogger.g?blogID=1098589623302643586#editor/target=post;postID=3255457773256582234;onPublishedMenu=posts;onClosedMenu=posts;postNum=0;src=postname

      Delete
  2. hi! the code you have written above, is applicable the way it is on matlab?

    ReplyDelete
  3. but why some of the line is missing or breaking?
    anyway to solve it?

    ReplyDelete
    Replies
    1. https://longdistance15.blogspot.com/2020/07/he-met-his-one-of-good-friends-who-was.html

      Delete
  4. 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

    ReplyDelete
  5. do u have code for rz polar and bipolar

    ReplyDelete
    Replies
    1. 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);

      Delete
  6. hi could you provide me a code for manchester and differential Manchester only
    .

    ReplyDelete
  7. I am working over a new digitizing scheme, but don't know how to program over matlab, can you help me please ....

    ReplyDelete
  8. please write the differential manchester code

    ReplyDelete
  9. 1xbet korean | legalbet.co.kr
    1xbet korean is a betting company with more than 5 years of experience in the industry. 바카라 Our business 1xbet is based in Namibia and deccasino it consists of three main

    ReplyDelete