Thursday, 23 April 2015

Differential Manchester signal

//code for diff. 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;
pulse=-1;
t=0:dt:T;
y=zeros(1,length(t));
  for i=0:(T-1);
         if x(i+1)==1
             if pulse==1
                 pulse=-1;
                 y(i*2*n+1 : (2*i+1)*n)=-1*pulse;
                 y((2*i+1)*n+1 : (2*i+2)*n)=pulse;
             else
                 pulse=1;
                 y(i*2*n+1 : (2*i+1)*n)=-1*pulse;
                 y((2*i+1)*n+1 : (2*i+2)*n)=pulse;
             end;
         end;
  end;
plot(t,y);
axis([0  t(end)  -2  2]);
grid on;
title('differential Manchester');



//end;

//the output is:-

this is the output

         



                                                                 Thank You !

























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 !
















Pseudoternary signal code in matlab

//code for pseudoternary

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

//end;


//the output is:-

this is the output of given input




                                 




                                                           THANK YOU !

















Bipolar AMI signal code in matlab

//code for Bipolar AMI

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

//end;

//the output is like this :-
this is the output of given input























NRZ-I signal matlab code

//codes for NRZ-I in matlab

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


the output is:-
this is the output as we given input






















NRZ-L Signal code in matlab

// code for   NRZ-L  signal

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


//end;


//the output is:-

this is the output of the signal as we given input
























codes for find poles and zeros on s-planes

//this code is for find poles and zeros in z-plane

clc;
clear;
close all;
num=input('Enter numerator coeff :-');
den=input('Enter denomenator coeff :-');
H=filt(num,den);
z=zero(H);
disp('zeros are at:-');
disp(z);      %find residue,pole location
[r,p,k]=residuez(num,den);
disp('poles are at:-');  
disp(p);
zplane(num,den);
H1=tf(num,den);
[p1,z1]=pzmap(H1);
disp('poles at:-');
disp(p1);
disp('zeros at:-');
disp(z1);
figure;
pzmap(H1);    %plot of pole zero map in s plane
title('pole-zero map of LTI system in s-plane');


//end  now run the code

//input
 Enter the numerator:-[1 1]
 Enter the denomenator:-[1 5 6]

Output is:-

zeros are at:-
     0
    -1

poles are at:-
   -3.0000
   -2.0000

poles at:-
   -3.0000
   -2.0000

zeros at:-
    -1