You are on page 1of 25

Experiment No.

1
Source Coding 1 (Text Coding & Compression using Huffman Coding) a. Find out relative frequencies or probabilities in a given text (Each student to use different text of about half page or one page). b. Design Huffman code using Computer program. The Computer program should have proper labels with lot of comment statements for the purpose of ease of readability. Details of special functions/sub-routines used should be included. c. Verify the computer generated code by the one obtained manually/analytically. d. Apply decoding and check whether you get back original data sequence. e. Find entropy of the source (text). f. How much compression (in terms of compression ratio or percentage compression) is obtained? Give comments on the results obtained.

Theory: Huffman codes are an important class of prefix codes. The basic idea behind
Huffman coding is to assign to each symbol of an alphabet a sequence of bits roughly equal in length to the amount of information conveyed by the symbol. The end result is a source code whose average codeword length approaches the fundamental limit set by the entropy of a discrete memoryless source.

Program:
%Huffman coding and decoding% function[a code dict] =scan(text) disp('Enter the text'); text= 'You add new functions to the MATLAB vocabulary by expressing them in terms of existing functions. The existing commands and functions that compose the new function reside in a text file called an M-file. M-files can be either scripts or functions. Scripts are simply files containing a sequence of MATLAB statements. Functions make use of their own local variables and accept input arguments. The name of an M-file begins with an alphabetic character and has a filename extension of .m. The M-file name, less its extension, is what MATLAB searches for when you try to use the script or function. A line at the top of a function M-file contains the syntax definition. The name of a function, as defined in the first line of the Mfile, should be the same as the name of the file without the .m extension.'; c=text; c n=length(c); a(1:91,1)=32:122; a(1:91,2)=0; %initialize the 2nd column of matrix by 0% %Calculation of frequencies of character for k=1:91; for i=1:n; if c(i)==31+k; a(k,2)=a(k,2)+1; end end end m=length(a);

%Removal of rows in which the frequency of character is 0 means the 2nd column is equal to 0% for i=m:-1:1; if a(i,2)==0; a(i,:)=[]; end m=length(a); end b=0; for i=1:m b=a(i,2)+b; end for l=1:m a(l,3)=a(l,2)/b; %calculation of probability of each character in a given text and making 3rd column in the matrix% end disp('The relative frequencies shown by 2nd column and probabilities shown by 3rd column in a given text is:'); a; %creating dictionary% [dict,avglen] =huffmandict(a(:,1),a(:,3)); disp('dictionary'); dict fprintf('The average length of huffman code is %f \n',avglen); % Calculation of Entropy % entro=0; for i=1:m; entro=entro+(a(i,3)*(log(1/a(i,3)))); end entropy=entro; disp('The resulted entropy is:'); disp(entropy); % Encoding % hcode= huffmanenco(c,dict);% encodes the signal sig using the Huffman codes described by the code dictionary dict% disp('The encoded text by huffman coding is'); disp(hcode); % Decoding % decoded=huffmandeco(hcode,dict);% decodes the numeric Huffman code vector comp using the code dictionary dict% disp('Result after decoding of huffman code'); disp(decoded); n=length(decoded); for i=1:n dectext(i)=char(decoded(i)); end disp('The decoded text'); disp(dectext);

Result obtained:
Enter the text: c= You add new functions to the MATLAB vocabulary by expressing them in terms of existing functions. The existing commands and functions that compose the new function reside in a text file called an M-file. M-files can be either scripts or functions. Scripts are simply files containing a sequence of MATLAB statements. Functions make use of their own local variables and accept input arguments. The name of an M-file begins with an alphabetic character and has a filename extension of .m. The M-file name, less its extension, is what MATLAB searches for when you try to use the script or function. A line at the top of a function M-file contains the syntax definition. The name of a function, as defined in the first line of the M-file, should be the same as the name of the file without the .m extension.

The relative frequencies shown by 2nd column and probabilities shown by 3rd column in a given text is: a= 32.0000 140.0000 44.0000 45.0000 4.0000 6.0000 0.1743 0.0050 0.0075 0.0137 0.0087 0.0037 0.0012 0.0037 0.0112 0.0012 0.0087 0.0012 0.0560

46.0000 11.0000 65.0000 66.0000 70.0000 76.0000 77.0000 83.0000 84.0000 89.0000 7.0000 3.0000 1.0000 3.0000 9.0000 1.0000 7.0000 1.0000

97.0000 45.0000

98.0000

7.0000

0.0087 0.0336 0.0149 0.0984 0.0386 0.0075 0.0349 0.0685 0.0012 0.0274 0.0212 0.0785 0.0498 0.0125 0.0012 0.0249 0.0560 0.0735 0.0237 0.0025 0.0087 0.0100 0.0075

99.0000 27.0000 100.0000 12.0000 101.0000 79.0000 102.0000 31.0000 103.0000 6.0000

104.0000 28.0000 105.0000 55.0000 107.0000 1.0000

108.0000 22.0000 109.0000 17.0000 110.0000 63.0000 111.0000 40.0000 112.0000 10.0000 113.0000 1.0000

114.0000 20.0000 115.0000 45.0000 116.0000 59.0000 117.0000 19.0000 118.0000 119.0000 120.0000 121.0000 2.0000 7.0000 8.0000 6.0000

dictionary dict =

[ 32] [ 44] [ 45] [ 46] [ 65] [ 66] [ 70] [ 76] [ 77] [ 83] [ 84] [ 89] [ 97] [ 98] [ 99] [100] [101] [102] [103] [104] [105] [107] [108] [109] [110]

[1x3 double] [1x7 double] [1x7 double] [1x6 double] [1x7 double] [1x8 double] [1x10 double] [1x8 double] [1x6 double] [1x10 double] [1x7 double] [1x10 double] [1x4 double] [1x7 double] [1x5 double] [1x6 double] [1x3 double] [1x5 double] [1x7 double] [1x5 double] [1x4 double] [1x10 double] [1x5 double] [1x5 double] [1x4 double]

[111] [112] [113] [114] [115] [116] [117] [118] [119] [120] [121]

[1x4 double] [1x6 double] [1x9 double] [1x5 double] [1x4 double] [1x4 double] [1x5 double] [1x9 double] [1x7 double] [1x6 double] [1x7 double]

The average length of huffman code is 4.321295 The resulted entropy is: 2.9700

The encoded text by huffman coding is: Columns 1 through 20 1 0 1 0 1 0 0 1 0 1 1 0 1 1 1 1 1 0 1 0

Columns 21 through 40 0 0 1 0 0 1 0 1 1 1 0 1 0 1 1 1 0 1 0 0

Columns 3441 through 3460 1 1 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1

Columns 3461 through 3470 0 0 1 0 0 1 1 1 1 1

Result after decoding of huffman code: Columns 1 through 20 89 111 117 32 97 100 100 116 105 111 110 Columns 21 through 40 115 32 116 111 118 111 99 97 32 116 104 101 32 77 65 84 76 65 66 32 32 110 101 119 32 102 117 110 99

. Columns 781 through 800 116 104 111 117 116 116 101 110 115 105 Columns 801 through 803 111 110 46 32 116 104 101 32 46 109 32 101 120

The decoded text: You add new functions to the MATLAB vocabulary by expressing them in terms of existing functions. The existing commands and functions that compose the new function reside in a text file called an M-file. M-files can be either scripts or functions. Scripts are simply files containing a sequence of MATLAB statements. Functions make use of their own local variables and accept input arguments. The name of an M-file begins with an alphabetic character and has a filename extension of .m. The M-file name, less its extension, is what MATLAB searches for when you try to use the script or function. A line at the top of a function M-file contains the syntax definition. The name of a function, as defined in the first line of the M-file, should be the same as the name of the file without the .m extension.

Experiment no.2
Source coding 2 (Arithmetic Coding) a) Find out relative frequencies or probabilities in a given text (Each student to use different text of about half page or one page). b) Design Arithmetic code using Computer program. c) Apply decoding and check whether you get back original data sequence. d) Give comments on the results obtained.

Program:
function [coding]=arithmetic(text) disp('entered text ='); text= 'You add new functions to the MATLAB vocabulary by expressing them in terms of existing functions. The existing commands and functions that compose the new function reside in a text file called an M-file. M-files can be either scripts or functions. Scripts are simply files containing a sequence of MATLAB statements. Functions make use of their own local variables and accept input arguments. The name of an M-file begins with an alphabetic character and has a filename extension of .m. The M-file name, less its extension, is what MATLAB searches for when you try to use the script or function. A line at the top of a function M-file contains the syntax definition. The name of a function, as defined in the first line of the Mfile, should be the same as the name of the file without the .m extension.'; c=text; disp(c); x=32:122; x=x'; x(:,2)=0; % calclation of frequency for i=1:length(c); for j=1:length(x); if c(i)==x(j,1); x(j,2)=x(j,2)+1; end end end % removal of redundant rows for i=91:-1:1; if x(i,2)==0; x(i,:)=[]; end end count=x(:,2); % calculation of probability x(:,3)=x(:,2)./length(c); disp('The relative frequencies and probability in a given text = ') disp(x) p=x(:,3);

% generation of sequence for i=1:91; x(i,4)=i; end for i=1:length(c); for j=1:91; if c(i)==x(j,1); seq(i)=x(j,4); end end end disp('seq =') disp(seq) % arithmetic coding code = arithenco(seq,count); %in this function count represents the source' statistics by listing the number of times each symbol of alphabet occurs in a test data set. disp('The code of a given text =') disp(code) % decoding decode = arithdeco(code,count,length(seq)); disp('The result after decoding =') disp(decode) % result in text form for i=1:length(decode); for j=1:91; if decode(i)==x(j,4); msg(i)=char(x(j,1)); end end end disp('The text after decoding =') disp(msg) % calculation of entropy h=-sum(p.*log2(p)); disp('Entropy =') disp(h) % calculation of saving. s=8*length(c); %calculate the length of uncoded text. t=length(code); %calculate the length of coded text. c=(s-t)/s; saving=c*100; %saving in percent disp('saving=') disp(saving)

Result Obtained: entered text =

You add new functions to the MATLAB vocabulary by expressing them in terms of existing functions. The existing commands and functions that compose the new function reside in a text file called an M-file. M-files can be either scripts or functions. Scripts are simply files containing a sequence of MATLAB statements. Functions make use of their own local variables and accept input arguments. The name of an M-file begins with an alphabetic character and has a filename extension of .m. The M-file name, less its extension, is what MATLAB searches for when you try to use the script or function. A line at the top of a function M-file contains the syntax definition. The name of a function, as defined in the first line of the M-file, should be the same as the name of the file without the .m extension. The relative frequencies and probability in a given text = 32.0000 140.0000 44.0000 45.0000 4.0000 6.0000 0.1743 0.0050 0.0075 0.0137 0.0087 0.0037 0.0012 0.0037 0.0112 0.0012 0.0087 0.0012 0.0560 0.0087 0.0336 0.0149 0.0984

46.0000 11.0000 65.0000 66.0000 70.0000 76.0000 77.0000 83.0000 84.0000 89.0000 7.0000 3.0000 1.0000 3.0000 9.0000 1.0000 7.0000 1.0000

97.0000 45.0000 98.0000 7.0000

99.0000 27.0000 100.0000 12.0000 101.0000 79.0000

102.0000 31.0000 103.0000 6.0000

0.0386 0.0075 0.0349 0.0685 0.0012 0.0274 0.0212 0.0785 0.0498 0.0125 0.0012 0.0249 0.0560 0.0735 0.0237 0.0025 0.0087 0.0100 0.0075

104.0000 28.0000 105.0000 55.0000 107.0000 1.0000

108.0000 22.0000 109.0000 17.0000 110.0000 63.0000 111.0000 40.0000 112.0000 10.0000 113.0000 1.0000

114.0000 20.0000 115.0000 45.0000 116.0000 59.0000 117.0000 19.0000 118.0000 119.0000 120.0000 121.0000 2.0000 7.0000 8.0000 6.0000

seq = Columns 1 through 20 12 26 32 1 31 21 26 25 13 16 16 1 25 17 34 1 18 32 25 15

Columns 21 through 40 30 26 1 31 26 15 13 1 31 20 17 1 9 5 11 8 5 6 1 33

.. Columns 781 through 800 31 17 20 25 26 30 32 21 31 1 31 20 17 1 4 24 1 17 35 31

Columns 801 through 803 26 25 4

The code of a given text = Columns 1 through 20 0 1 0 0 1 1 1 1 0 1 0 1 1 0 1 1 1 0 0 0

Columns 21 through 40 0 1 0 0 1 1 1 0 0 1 0 1 0 1 1 0 0 1 1 1

. . Columns 3421 through 3440

1 0 0 0 1 0

Columns 3441 through 3452

The result after decoding = Columns 1 through 20 12 31 26 21 32 26 1 13 25 16 16 1 25 17 34 1 18 32 25 15

Columns 21 through 40 30 26 1 31 26 15 13 1 31 20 17 1 9 5 11 8 5 6 1 33

. Columns 781 through 800 31 17 20 25 26 30 32 21 31 1 31 20 17 1 4 24 1 17 35 31

Columns 801 through 803 26 25 4

The text after decoding = You add new functions to the MATLAB vocabulary by expressing them in terms of existing functions. The existing commands and functions that compose the new function reside in a text file called an M-file. M-files can be either scripts or functions. Scripts are simply files containing a sequence of MATLAB statements. Functions make use of their own local variables and accept input arguments. The name of an M-file begins with an alphabetic character and has a filename extension of .m. The M-file name, less its extension, is what MATLAB searches for when you try to use the script or function. A line at the top of a function M-file contains the syntax definition. The name of a function,

as defined in the first line of the M-file, should be the same as the name of the file without the .m extension.

Entropy = 4.2848

saving= 46.2640

Experiment no.3(a) Basic Digital Communication. (a). Computer based Generation of random binary data and its verification. Program:
close all; clear all; clc; %random binary data% n=input('Enter the number of binary sequence:') A=randint(1,n); %finding no. of ones% N1=max(size(find(A==1))); %finding no. of zeroes% Z0=max(size(find(A==0))); totalsize=N1+Z0; fprintf('\n total length of binary sequence is %i\n',totalsize); fprintf('\n No of ones in binary sequence is: %i',N1); fprintf('\n No of zeroes in binary sequence is: %i\n',Z0); %Verification:calculate the probability of ones and zeroes as to 50 perc% disp('Probability of ones and zeroes respectively'); %probability of ones% ones=N1/totalsize; disp(ones); %probability of zeroes% zeroes=Z0/totalsize; disp(zeroes);

Result Obtained: Enter the number of binary sequence:10000

n=

10000

total length of binary sequence is 10000 No of ones in binary sequence is: 5042 No of zeroes in binary sequence is: 4958 Probability of ones and zeroes respectively 0.5042

0.4958

Experiment no.3(b)
(b) Computer based Generation of AWGN for a specific value of mean, and standard deviation. Use computer program to find the pdf, mean value, and standard deviation of the generated sequence. Each student should generate a different sequence using a different value of seed integer. Program:
clear all; clc; n=input('Enter the sequence length:'); noise=normrnd(0,1,1,n); %finding the mean% avg=mean(noise); %finding the standard deviation% stddev=std(noise); %plot the experimental and practical% x=-4:0.01:4; pd=normpdf(x,avg,stddev); theoritical=[-2:.01:2]; pdn=normpdf(theoritical,0,1); plot(theoritical,pdn,'r:'); hold on plot(x,pd,'b-'); legend('theoritical','practical'); hold off xlabel('x'); ylabel('prob density function p(x)'); fprintf('\n The mean value is: %i',avg); fprintf('\n The standard deviation is: %i\n',stddev);

Result Obtained: Enter the sequence length:10000 The mean value is: 1.884803e-003 The standard deviation is: 9.874310e-001

P t of ex erim l andthe lo p enta oritical p df 0.4 0.3 5 0.3 prob density function p(x) 0.2 5 0.2 0.1 5 0.1 0.0 5 0 -4 the oritical pra ctical

-3

-2

-1

0 x

Experiment No. 4
Baseband Binary Signalling over AWGN channel. a. Write a program to simulate a baseband binary signaling (e.g. BPSK) over an AWGN channel and using threshold detector at the receiver. Find the BER vs SNR curve. Make sure that enough bits are transmitted at different SNRs to get an accurate curve. b. Compare the curve obtained in (a) above with the empirically obtained curve using the formula for BER vs SNR. c. Check whether MATLAB or some of its tool-box has some readymade command for this kind of curve to be obtained. Program:
% Baseband signaling clear all; clc; n=input('Enter the length of binary sequence:'); inptsig = randn(1,n); SNR=input('\nEnter the SNR value:'); %Generation of BPSK signal over an awgn channel for i=1:n if(inptsig(i)>0) inptdata(i)=+1; else inptdata(i)=-1; end end disp('The transmitted signal is:'); for i=1:n fprintf('%i',inptdata(i)); end %AWGN channel simulation for j=0:SNR awgnsig = awgn(inptsig,j); for i=1:n if(awgnsig(i)>0) rcvdata(i)=1; else rcvdata(i)=-1; end end %Bit error rate calculation corct=0; incrct=0; for i=1:n

end ber(j+1)=incrct/n; end % Ploting BER vs SNR both by simulated data snr= 0:SNR; subplot(2,1,1); semilogy(snr,ber); grid on xlabel('SNR (dB)'); ylabel('BER '); legend('experimental'); title('BER vs SNR curve for BPSK'); subplot(2,1,2); semilogy(snr,0.5*erfc(snr/4)); grid on xlabel('SNR (dB)'); ylabel('BER '); legend('theoritical'); title('BER vs SNR Curve for BPSK over AWGN');

if(inptdata(i)==rcvdata(i)) corct=corct+1; else incrct=incrct+1; end

Result Obtained:
Enter the length of binary sequence:1000 Enter the SNR value:20 The transmitted signal is: 11-1111111-11-11-111-111-111-1-111-1-1-1-1111-1-1-111-1-1-11-1-111-1111-1-1-1-1-11-1-111111111-1-11-111-1-1-11-1-11-1-1-1-11-111-11111-11-1-111-1-1-1-11-1-11111-1111-11-11-1-11-1-11-1-1-111-1-1-1-1111-1-1-111-1111-111-1-1-1-1-1-1-1-11-1-1-11-1-1111-1-1-111-1-1-11-1-111-11-11-1-1-1111-11-11-1-11-1111-1-111-1-11-111111-11-1-1-111-1-1-111-11-1-111-111-11-111-1-11-1-1-1-1-1-11-111-1-11-1111-1-1-1-1-1111-1-1-1-1-111-11-111-1-1-111111111-1-111-11-111-11-11-1-11-1-111-111111-1-111-11-111111-1-111-11-1-1-11-11-11-1-1-11111-1-1-1-11-111-11-1111-1-111-11-11-1-1-11111-11-1-111-1-11-1-1-1-11-1-1-1-1-1-111-11-1-1-111-1-11-1-1-11-11-1-11-1-1-1-111-11-1-11-1-1-1111-1-1-11111-11-1-1-1-1111-11-11-11-1-1-1-11-1-1-11-1-111-1-1-1-11-1-111-1111-1111111-11-111111-11-11-1-11-111-1-11-1-11111-1-1-1-111-11-11-1-111-1111-1-1-1-111-111-1-1-11-11-1-11-1111-1-1-11-111-11-11-1-11111-1-11-1-111-1-11-11-11-1-1-1111111-11-111-11-1-1-1-1-1-111-111111111-11-11111111-11-1111-1-11-11-11-11-11-11-111-1-1-1111-1111111-1-1-11-1-1-1-1-11111-11111-1-111-111-111-11-1-1-1-111-1111-1-11111-11-111-111-1111-1-1-1-1-1-1-1-11-111-1-111-1111111-1-11111-1-1-1-11-11-1-11111-1111-1-11-1-1-1-1-1-1-1-11-1-11-1-111-11-1-111111-11-1-1111-111-1-111-1-1-1-111-1-1-1-1-1-11-1111111-11-11-1-1-1-11-11-11-1-111111-11-1-11-111-1-1-1-1-11-11-1-11-11-11-111111-111-1-1-1-1111-1-11-111-1-11-11-1-11-111-1-1-111111-111-1-1111-1-11-1111-111-1111-11-11-11-1-11-1-11-1111-111-1-11-11-1-11-1-1-1-11-11-11-111-1-11-1-1-111-111-1-1-1-111-11-11-11

1 0

BRs Ncr eoBS E v SRu f r PK v e e et l xr n p im a

B R E

1 0

1 0

1 0 1 0 1 0 1 0

1 0 SRd) N( B BRs NCv f rBS o rA G E v SR u eo PKv W r e N

1 5

2 0

t er i a ho cl it
5

B R E

-0 1

-5 1

1 0 SRd) N( B

1 5

2 0

Comments: We will get the better BER vs SNR curve if we transmit more number of bit.

BER Vs SNR can also be analyzed by MATLAB, as it has a readymade tool for that so called bertool and can be open by the same command.

Experiment no: 5
Baseband Binary signaling over channel with ISI and AWGN a) Simulate a channel having a sampled impulse response of two components. b) Find the BER vs SNR for baseband BPSK signaling over this channel, and compare the results obtained in expt. 4. c) Design a suitable linear feed-forward transversal equalizer(s) for the given channel. Again obtain the BER vs SNR curve experimentally through a computer simulation program. d) Comment on the results obtained.

Part (a) Calculation of Equalizer impulse response Program:


%This program is to find out the equalizer impulse response close all; clear all; clc; N = input('Type in the length of output vector = '); % Read the numerator and denominator coefficients num = input('Type in the numerator coefficients = '); den = input('Type in the denominator coefficients = '); % Compute the desired number of inverse transform coefficients x = [1 zeros(1, N-1)]; y = filter(num, den, x); disp('Coefficients of the power series expansion'); disp(y); Result Obtained:

Type in the length of output vector = 2 Type in the numerator coefficients = 1 Type in the denominator coefficients = [0.6 0.4] Coefficients of the power series expansion 1.6667 -1.1111

Part (b) Program to find out BER vs SNR for baseband BPSK signaling without using equalizer Program:
%This program is to generate the binary data and transmit it on the %distorted cannel of impulse response [0.8 0.6] with modulation technique %BPSK %Base-band Binary signaling over Gaussian Channel close all; clear all; clc; N=input ('Enter the length of data :'); S= input('Enter the SNR value :'); tx=randn(1,N); SNR=S; c=[0.8 0.6]; %Generation of BPSK signal over an awgn channel for n=1:N if (tx(n)>0) tx_data(n)=1; else tx_data(n)=-1; end end % AWGN channel simulation for snr=0:SNR Rx=awgn(tx_data,snr,'measured','dB'); Rt=conv(Rx,c); %Thershold detection of received signal for n=1:N if(Rt(n)>0) rx(n)=1; else rx(n)=-1; end end % Bit error rate calculation hit=0; miss=0; for n=1:N if(rx(n)==tx_data(n))

hit=hit+1; else miss=miss+1; end end BER(snr+1)=miss/N; end ber= smooth(BER); % Ploting BER vs SNR both by simulated data S=0:SNR; subplot(211);semilogy(S,ber,'r'); grid on xlabel('SNR in dB'); ylabel('BER'); title('BER Vs SNR curve for BPSK over AWGN without equalizer'); legend('simulated'); subplot(212);semilogy(S,0.5*erfc(S./4)); grid on title('BER Vs SNR curve for BPSK over AWGN without equalizer'); xlabel('SNR in dB'); ylabel('BER'); legend('Theoretical');

Result Obtained:
Enter the length of data :10000 Enter the SNR value :20

1 0 1 0 1 0 1 0

BRs Ncr eoBS o rA Gw oteulzr E VSRu f r PKv W it u qa e v e Nh i s ut d im e l a

B R E

1 0 1 0 1 0 1 0

1 0 SR d Nin B BRs Ncr eoBS o rA Gw oteulzr E VSRu f r PKv W it u qa e v e Nh i

1 5

2 0

Ter t a ho icl e
5

B R E

-0 1

-5 1

1 0 SR d Nin B

1 5

2 0

Part (c) Program to find out BER vs SNR for baseband BPSK signaling using equalizer Program:
%This program is to generate the binary data and transmit it on the %distorted cannel of impulse response [0.8 0.6] and equalizer used here is %of 6 tap close all; clear all; clc; N=input ('Enter the length of binary data :'); S= input('Enter the SNR value :'); tx=randn(1,N); SNR=S; c=[0.8 0.6]; %Generation of BPSK signal over an awgn channel for n=1:N if (tx(n)>0) tx_data(n)=1; else tx_data(n)=-1; end

end % AWGN channel simulation for snr=0:SNR Rx=awgn(tx_data,snr,'measured','dB'); Rt=conv(Rx,c); Tap=[1.2500 -0.9375 0.7031 -0.5273 R=conv(Rt,Tap); %Thershold detection of received signal for n=1:N if(R(n)>0) rx(n)=1; else rx(n)=-1; end end % Bit error rate calculation hit=0; miss=0; for n=1:N if(rx(n)==tx_data(n)) hit=hit+1; else miss=miss+1; end end BER(snr+1)=miss/N; end % Ploting BER vs SNR both by simulated data S=0:SNR; semilogy(S,BER) grid on xlabel('SNR in dB'); ylabel('BER'); title('BER Vs SNR curve for BPSK over AWGN with equalizer ');

0.3955

-0.2966];

Result Obtained: Enter the length of binary data : 10000 Enter the SNR value : 25

1 0

B RV S Rc rv fo B S o e A G w e u liz r E s N u e r P K v r W N ith q a e

1 0

-1

BE R

1 0

-2

1 0

-3

1 0

-4

6 8 S Rind N B

1 0

1 2

1 4

Comments: It can be seen from the above figures that error performance degrades when channel impulse response also comes into picture. When equalization is done error performance improves.

You might also like