# Demo entry 2839848

**4.1**

Submitted by **anonymous**
on Oct 08, 2015 at 20:03

Language: Matlab. Code size: 884 Bytes.

x=randi([0 1],1,1000000); block_length=53; %Finds how many zeros to be added count=(block_length*(floor(size(x)/block_length)+1))-size(x); count_n=count(1,2); p=0.7; %Generating array with no. of 1s with probability <p binaryArray=rand(size(x))<p; binaryArray=[binaryArray,zeros(1,count_n)]; length=size(binaryArray); no_block=length(1,2)/block_length; i=1; n=0; total_error=[0 0 0]; %Implementing BSC for each block while n < no_block; block=binaryArray(i:i+block_length-1); %Finding consecutive errors out=find(diff([0 block 0]) == -1) - find(diff([0 block 0]) == 1); sort(out); u = [1 2 3]; Ncount=histc(out,u); %Count number of 1-bit,2-bit,3-bit errors Ncount=Ncount>=1; %Avoiding counting two 2-bit errors as 2 single bit errors also total_error=total_error+Ncount; i=i+block_length; n=n+1; end; total_error

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.