## Duobianry Signaling-Amplitude & Phase Response

March 28, 2012 Coded in Scilab
``````function [Amplitude_Response,Phase_Response]= Duobinary_Signaling()
//Duobinary Signaling Scheme
//Magnitude and Phase Response
rb =  input('Enter the bit rate=');
Tb =1/rb;  //Bit duration
f = -rb/2:1/100:rb/2;
Amplitude_Response = abs(2*cos(%pi*f.*Tb));
Phase_Response = -(%pi*f.*Tb);
subplot(2,1,1)
a=gca();
a.x_location ="origin";
a.y_location ="origin";
plot(f,Amplitude_Response)
xlabel('Frequency f---->')
ylabel('|H(f)| ----->')
title('Amplitude Repsonse of Duobinary Singaling')
subplot(2,1,2)
a=gca();
a.x_location ="origin";
a.y_location ="origin";
plot(f,Phase_Response)
xlabel('                                           Frequency f---->')
ylabel('                                            <H(f) ----->')
title('Phase Repsonse of Duobinary Singaling')
endfunction
//Result
//-->exec('C:\Users\SENTHILKUMAR\Desktop\Communication_Toolbox\Digital_Communication\New folder\Duobinary_Signaling.sci', -1)
//
//-->[Amplitude_Response,Phase_Response]= Duobinary_Signaling()
//Enter the bit rate= 8``````

## Equalizer to compensate aperture effect

March 28, 2012 Coded in Scilab
``````function [E]=EqualizerFor_ApertureEff(Ts)

//Equalizer to Compensate for aperture effect
T_Ts = 0.01:0.01:Ts;
E(1) =1;
for i = 2:length(T_Ts)
E(i) = ((%pi/2)*T_Ts(i))/(sin((%pi/2)*T_Ts(i)));
end
a =gca();
a.data_bounds = [0,0.8;0.8,1.2];
plot2d(T_Ts,E,5)
xlabel('Duty cycle T/Ts')
ylabel('1/sinc(0.5(T/Ts))')
title('Normalized equalization (to compensate for aperture effect) plotted versus T/Ts')
endfunction``````

## Repetition code

March 28, 2012 Coded in Scilab
``````function [G,H,x]=RepetitionCode(n,k,m)

//Repetition Codes
//n =block of identical 'n' bits
//k =1 one bit
//m = 1;// bit value = 1
I = eye(n-k,n-k);//Identity matrix
P = ones(1,n-k);//coefficient matrix
H = [I P'];//parity-check matrix
G = [P 1];//generator matrix
x = m.*G; //code word
disp(G,'generator matrix');
disp(H,'parity-check matrix');
disp(x,'code word for binary one input');
endfunction
//Result
//-->exec('C:\Users\SENTHILKUMAR\Desktop\Communication_Toolbox\Digital_Communication\RepetitionCode.sci', -1)
//
//-->n = 5
// n  =
//
//    5.
//
//-->k =1
// k  =
//
//    1.
//
//-->m =1
// m  =
//
//    1.
//
//-->[G,H,x]=RepetitionCode(n,k,m)
//
// generator matrix
//
//    1.    1.    1.    1.    1.
//
// parity-check matrix
//
//    1.    0.    0.    0.    1.
//    0.    1.    0.    0.    1.
//    0.    0.    1.    0.    1.
//    0.    0.    0.    1.    1.
//
// code word for binary one input
//
//    1.    1.    1.    1.    1.
// x  =
//
//    1.    1.    1.    1.    1.
// H  =
//
//    1.    0.    0.    0.    1.
//    0.    1.    0.    0.    1.
//    0.    0.    1.    0.    1.
//    0.    0.    0.    1.    1.
// G  =
//
//    1.    1.    1.    1.    1.``````

## Reed Solomon Codes

March 28, 2012 Coded in Scilab
``````function[n,p,r] = ReedSolomon_Codes(m)

// Reed-Solomon Codes
//Single-error-correcting RS code with a 2-bit byte
//m = m-bit symbol
k = 1^m; //number of message bits
t =1; //single bit error correction
n = 2^m-1; //code word length in 2-bit byte
p = n-k; //parity bits length in  2-bit byte
r = k/n; //code rate
disp(n,'code word length in 2-bit byte n =')
disp(p,'parity bits length in  2-bit byte n-k=')
disp(r,'Code rate:r = k/n =')
disp(2*t,'It can correct any error upto =')
endfunction
//Result
//-->exec('C:\Users\SENTHILKUMAR\Desktop\Communication_Toolbox\Digital_Communication\ReedSolomon_Codes.sci', -1)
//
//-->m=2
// m  =
//
//    2.
//
//-->[n,p,r] = ReedSolomon_Codes(m)
//
// code word length in 2-bit byte n =
//
//    3.
//
// parity bits length in  2-bit byte n-k=
//
//    2.
//
// Code rate:r = k/n =
//
//    0.3333333
//
// It can correct any error upto =
//
//    2.
// r  =
//
//    0.3333333
// p  =
//
//    2.
// n  =
//
//    3.
//``````

## Direct Sequence Spread Spectrum (DS-BPSK)

March 28, 20121 comment Coded in Scilab
``````function[st,mt]= DS_Spread_Spectrum(bt,ct_polar)
//Generation of waveforms in DS/BPSK spread spectrum transmitter
//bt: Input Data Sequence (bipolar format)
Ft = 0:0.01:1;
//bt = [1*ones(1,N) -1*ones(1,N)];
t = 0:length(bt)-1;
//ct_polar = [-1,-1,1,1,1,-1,1,-1,-1,1,1,1,-1,1];
mt = bt.*ct_polar;
Carrier = 2*sin(Ft*2*%pi);
st = [];
for i = 1:length(mt)
st = [st mt(i)*Carrier];
end
//
figure
subplot(3,1,1)
a =gca();
a.x_location = "origin";
a.y_location = "origin";
a.data_bounds = [0,-2;20,2];
plot2d2(t,bt,5)
xlabel('                                                               t')
title('Data b(t)')
subplot(3,1,2)
a =gca();
a.x_location = "origin";
a.y_location = "origin";
a.data_bounds = [0,-2;20,2];
plot2d2(t,ct_polar,5)
xlabel('                                                                t')
subplot(3,1,3)
a =gca();
a.x_location = "origin";
a.y_location = "origin";
a.data_bounds = [0,-2;20,2];
plot2d2(t,mt,5)
xlabel('                                                               t')
title('Product Signal m(t)')
//
figure
subplot(3,1,1)
a =gca();
a.x_location = "origin";
a.y_location = "origin";
a.data_bounds = [0,-2;20,2];
plot2d2(t,mt,5)
xlabel('                                                                t')
title('Product Signal m(t)')
subplot(3,1,2)
a =gca();
a.x_location = "origin";
a.y_location = "origin";
a.data_bounds = [0,-2;20,2];
plot(Carrier)
xlabel('                                                               t')
title('Carrier Signal')
subplot(3,1,3)
a =gca();
a.x_location = "origin";
a.y_location = "origin";
a.data_bounds = [0,-2;20,2];
plot(st)
xlabel('                                                               t')
title('DS/BPSK signal s(t)')
endfunction
//Result
//->bt = [1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1]
// bt  =
//
//    1.    1.    1.    1.    1.    1.    1.  - 1.  - 1.  - 1.  - 1.  - 1.  - 1.  - 1.
//
//-->ct_polar = [-1,-1,1,1,1,-1,1,-1,-1,1,1,1,-1,1]
// ct_polar  =
//
//  - 1.  - 1.    1.    1.    1.  - 1.    1.  - 1.  - 1.    1.    1.    1.  - 1.    1.
//
//
// mt  =
//
//  - 1.  - 1.    1.    1.    1.  - 1.    1.    1.    1.  - 1.  - 1.  - 1.    1.  - 1.``````

## Convolutional coding using transform domain approach

March 28, 2012 Coded in Scilab
``````function [x1D,x2D]= ConvolutionCode_TransDomain()
//Convolutional code - Transform domain approach
//g1D =  generator polynomial 1
//g2D =  generator polynomial 2
//x1D = top output sequence polynomial
//x2D = bottom output sequence polynomial
D = poly(0,'D');
g1D = input('Enter the generator polynomial 1=') //generator polynomial 1
g2D = input('Enter the generator polynomial 2=') //generator polynomial 2
mD = input('Enter the message sequence')//message sequence polynomial representation
x1D = g1D*mD; //top output polynomial
x2D = g2D*mD; //bottom output polynomial
x1 = coeff(x1D);
x2 = coeff(x2D);
disp(modulo(x1,2),'top output sequence')
disp(modulo(x2,2),'bottom output sequence')
endfunction
//Result
//Enter the generator polynomial 1 =  1+D+D^2
//Enter the generator polynomial 2 =  1+D^2;
//Enter the message sequence = 1+0+0+D^3+D^4;
//top output sequence
//
//    1.    1.    1.    1.    0.    0.    1.
//bottom output sequence
//
//    1.    0.    1.    1.    1.    1.    1.
//x2D  =
//
//         2   3   4   5   6
//    1 + D + D + D + D + D
//x1D  =
//
//             2   3    4    5   6
//    1 + D + D + D + 2D + 2D + D``````

## Constellation Diagram for Binary QPSK

March 28, 20122 comments Coded in Scilab
``````function[y] = Constellation_QPSK()
M =4;
i = 1:M;
y = cos((2*i-1)*%pi/4)-sin((2*i-1)*%pi/4)*%i;
annot = dec2bin([0:M-1],log2(M));
disp(y,'coordinates of message points')
disp(annot,'dibits value')
figure;
a =gca();
a.data_bounds = [-1,-1;1,1];
a.x_location = "origin";
a.y_location = "origin";
plot2d(real(y(1)),imag(y(1)),-2)
plot2d(real(y(2)),imag(y(2)),-4)
plot2d(real(y(3)),imag(y(3)),-5)
plot2d(real(y(4)),imag(y(4)),-9)
xlabel('                                             In-Phase');
title('Constellation for QPSK')
legend(['message point 1 (dibit 10)';'message point 2 (dibit 00)';'message point 3 (dibit 01)';'message point 4 (dibit 11)'],5)
endfunction
//Result
//coordinates of message points
//  0.7071068 - 0.7071068i  - 0.7071068 - 0.7071068i  - 0.7071068 + 0.7071068i    0.7071068 + 0.7071068i
//
// dibits value
//
//!00  01  10  11  !``````

## Constellation diagram for Binary PSK

March 28, 2012 Coded in Scilab
``````function[y]= Constellation_BPSK()
M =2;
i = 1:M;
y = cos(2*%pi+(i-1)*%pi);
annot = dec2bin([length(y)-1:-1:0],log2(M));
disp(y,'coordinates of message points')
disp(annot,'Message points')
figure;
a =gca();
a.data_bounds = [-2,-2;2,2];
a.x_location = "origin";
a.y_location = "origin";
plot2d(real(y(1)),imag(y(1)),-9)
plot2d(real(y(2)),imag(y(2)),-5)
xlabel('                                                                      In-Phase');
title('Constellation for BPSK')
legend(['message point 1 (binary 1)';'message point 2 (binary 0)'],5)
endfunction
//Result
//coordinates of message points
//
//    1.  - 1.
//
// Message points
//
//!1  0  !``````

## Constellation for Binary FSK

March 28, 2012 Coded in Scilab
``````function[y]= Constellation_BFSK()
M =2;
y = [1,0;0,1];
annot = dec2bin([M-1:-1:0],log2(M));
disp(y,'coordinates of message points')
disp(annot,'Message points')
figure;
a =gca();
a.data_bounds = [-2,-2;2,2];
a.x_location = "origin";
a.y_location = "origin";
plot2d(y(1,1),y(1,2),-9)
plot2d(y(2,1),y(2,2),-5)
xlabel('                                                                      In-Phase');
title('Constellation for BFSK')
legend(['message point 1 (binary 1)';'message point 2 (binary 0)'],5)
endfunction
//Result
//coordinates of message points
//
//    1.    0.
//    0.    1.
//
// Message points
//
//!1  0  !``````

## Circular Convolution

March 3, 2012 Coded in Matlab
``````%circular convolution
%for testing you may use:
h = fir1(20,.3);
x = randn(1,1024);

%function y = conv_circ(h,x)

y = conv(h,x);

L1 = length(h);
L2 = length(x);