Thursday, 23 April 2015

Manchester signal code in matlab

//code for Manchester signal

clc;
clear;
x=[0 1 0 1 0 0 0 1 1 0 1 1 0 0 0 1];
T=length(x);
n=100;
N=2*n*T;
dt=T/N;
t=0:dt:T;
y=zeros(1,length(t));
    for i=0:1:(T-1);
        if x(i+1)==1
            y(i*2*n+1 : (2*i+1)*n)=-1;
            y((i*2+1)*n+1 : (2*i+2)*n)=1;
        else
            y(i*2*n+1 : (2*i+1)*n)=1;
            y((2*i+1)*n+1 : (2*i+2)*n)=-1;
        end;
    end;
     plot(t,y);
     axis([0 t(end) -2 2]);
     grid on;
     title('Manchester');


//end;


//the output is:-

this is the output








                                                               Thank You !
















2 comments:

  1. Hi Mr Gautam,
    Can you please write as a comment in front of each code so i can understand what each code means ? Thank you

    ReplyDelete