PN Seq

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Exp.No.

14

BLOCK CODE GENERATION

AIM: To simulate Block codes using Matlab REQUIREMENTS: Personal computer MATLAB 7

THEORY: A block code is a code in which k bits or more generally symbols are input and n bits are output. We designate the code as an (n; k) code. Each message of n symbols associated with a with each input block is called a codeword. We could, in general, simply have a lookup table with k inputs and n outputs. However, as k gets large, this quickly becomes infeasible. A block code C of length n with 2k codewords is called a linear (n; k) code if and only if its 2k code words form a k-dimensional subspace of the vector space of all n-tuples. More generally, with a bigger field, a block code C of length n with qk is called a linear (n; k) code if and only if its qk code words form a k-dimensional subspace of the vector space of all n-tuples .

PROGRAM: clc; clear; w=[1 0 0 0 1 0]; fprintf(The original code is:); disp(w); P=[1 1 0; 0 1 1; 0 0 1]; I=[1 0 0; 0 1 0; 0 0 1]; pt=P`; H=[pt,I];

ht=H; disp(ht); for(i=1:3) s1=0; for(j=1:6) s1xor(s1,ht(j,i)*w(j)); end s(i)=s1; end fprint(The syndrome is:); disp(s); for(k=1:6); if(s==ht(k,:)) temp=k; end end fprintf(The error is in the position %d\n,temp); w(temp)=xnor(w(temp),1); disp(Corrected code is:); disp(w)

OUTPUT The original code is: 1 1 0 1 1 0 1 0 0 0 1 0

0 1 0 0

0 0 1 0

1 0 0 1 1 0 0

The syndrome is:

The error is in the position 4 Corrected code is: 1 0 0 1 1 0

Result: Block code is generated using Matlab

Exp.No. 13

PN SEQUENCE GENERATION

AIM: To simulate PN Sequence using Matlab REQUIREMENTS: Personal computer MATLAB 7

THEORY: The PN Sequence Generator block generates a sequence of pseudorandom binary numbers. A pseudo noise sequence can be used in a pseudorandom scrambler and descrambler. It can also be used in a direct-sequence spread-spectrum system.The schematic of the pseudorandom sequence generator is shown below. All adders perform addition modulo 2.

All M registers in the generator update their values at each time step. The state of each switch is defined by the generator polynomial, which is a polynomial in z-1 having binary coefficients. The constant term of the generator polynomial must be 1. You can specify the Generator polynomial parameter using either of these formats:

A vector of coefficients of the polynomial, starting with the constant term and proceeding in order of increasing powers of z-1. The first and last elements must be 1. A vector containing the exponents of z (not z-1) for the nonzero terms of the polynomial. The first element must be zero.

For example, p = [1 0 0 0 0 0 1 0 1] and p = [0 -6 -8] represent the same polynomial p(z) = 1 + z-6 + z-8. It is very important that the Initial states parameter have a suitable value. The initial state of at least one of the registers must be nonzero in order to generate a nonzero sequence. The length of the Initial states vector must equal the order of the generator polynomial, and its elements must be binary numbers. If the Generator polynomial parameter is a vector that lists the coefficients in order, then the order of the generator polynomial is one less than the vector length.

PROGRAM:

clc; clear; x=input(Enter the Number of Registers:); len=(2^x)-1; fprintf(\nInital state of the Registers:); for i=1:x if(i==1) r(i)=1; else r(i)=0; end fprintf(\t%d,r(i)); end

%Balance property% ones=0; zeros=0; for i=1:len if(p(i)==1) ones=ones+1; else zeros=zeros+1; end

end if(ones>zeros) fprintf(\n\nBalance property is satisfied\n); else fprintf(\n\nBalance property is not satisfied\n); end

%run length property% Run=0; for j=1(len-1) if(p(j)~=p(j+1)) run=run+1; end end frprintf(\n no of runs=%d\n,run); if(run==(2^(x-1))) fprintf(\nRun length property is satisfied); else fprintf(\nRun length property is not satisfied); end

%Autocorrelation property% temp=p(len); fprintf(\n\nPN Sequence after shifting:); output=p;

for j=len:-1:2 output(j)=output(j-1); end output(1)=temp; fprintf(\t%d,output); agree=0; disagree=0; for j=1:len if(output(j)==p(j)) agree=agree+1; else disagree=disagree+1; end end if(disagree>agree) fprintf(\n\nAuto correlation property is satisfied\n); else fprintf(\n\nAuto correlation property is not satisfied\n); end Output 1 Enter the Number of Registers:3 Initial state of the Registers: 1 PN Sequence : 0 0 1 1 1 0 1 0 0

Balance property is statisfied

No of runs=3 Runs length property is not satisfied PN Sequence after shifting: 1 0 0 1 1 1 0

Auto correlation property is satisfied Output 2 Enter the Number of Registers:4 Initial state of the Registers: 1 PN Sequence :0 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0 1

Balance property is satisfied No of runs=7 Runs length property is not satisfied PN Sequence after shifting:1 0 0 1 0 1 1 0 0 0 1 0 1 1 1

Auto correlation property is satisfied

Result: PN sequence is generated using Matlab

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy