LDPC s-function to calculate PER

1 view (last 30 days)
Wen Pang
Wen Pang on 6 Dec 2016
I was working on a project to investigate the performance of LDPC code in WSN. I'm running the project by using MATLAB Simulink. Hence, I had written a s-function to calculate the Packet Error Rate where any 1 bit of error in a packet will be considered as 1 PER. Unfortunately, my s-function block is not working properly but i couldnt spot where is my mistake. I hereby paste the my program down here. Can anyone please kindly correct me? For your information, there is a 2-bit delay in the block.
long i=0,j=0, PE=0;
if (temp != u1[0] && last_PE != 1) { BER++; PE=1; }
last_PE = 0;
for ( i=0; i<81; i++) { for ( j=0; j<400; j++) { if (u0[i*400+j]!=u1[i*400+j+2]) { BER++; PE=1; }
}
if (PE==1)
{
PER++;
PE=0;
}
}
i=81; for ( j=0; j<399; j++) { if (u0[i*400+j]!=u1[i*400+j+2]) { BER++; PE=1; last_PE = 1; } } /* to compare the last bit of the last packet,if there is an error, BER increase and PE=1*/ temp= u0[i*400+399]; /* to store the last bit temporary for comparison later on*/
if (PE==1) { PER++; PE=0; }
y0[0]=BER; y0[1]=PER;

Answers (0)

Categories

Find more on Block and Blockset Authoring in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!