⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bound_313.c

📁 error correction code
💻 C
字号:
// ------------------------------------------------------------------------
// File: bound_313.c
//
// Probability of error of a repetition code over an AWGN channel
// with soft decision decoding
// ------------------------------------------------------------------------
// This program is complementary material for the book:
//
// R.H. Morelos-Zaragoza, The Art of Error Correcting Coding, Wiley, 2002.
//
// ISBN 0471 49581 6
//
// This and other programs are available at http://the-art-of-ecc.com
//
// You may use this program for academic and personal purposes only. 
// If this program is used to perform simulations whose results are 
// published in a journal or book, please refer to the book above.
//
// The use of this program in a commercial product requires explicit
// written permission from the author. The author is not responsible or 
// liable for damage or loss that may be caused by the use of this program. 
//
// Copyright (c) 2002. Robert H. Morelos-Zaragoza. All rights reserved.
// ------------------------------------------------------------------------


#include <stdio.h>
#include <math.h>
#include <float.h>
#include <limits.h>

main(argc,argv)
int argc;
char **argv;
{
  double n, init,final,inc,  eb_no_db, es_no;
  double sum, rate, d12;
  char name[40];   
  
  double Q(double a);
  double erfc( double x );
  FILE *fp;

  if (argc != 5)
  {
    printf("Usage: %s output_file init_SNR final_SNR inc_SNR\n",
    argv[0]);
    exit(1);
  }
  sscanf(argv[1], "%s", name);
  sscanf(argv[2], "%lf", &init);
  sscanf(argv[3], "%lf", &final);
  sscanf(argv[4], "%lf", &inc);

  fp = fopen(name,"w");
  printf("\nEb/No       \t   BER\n");
  
  n = 3.0;
  rate = 1.0/3.0;
  d12 = 3.0;

  for (eb_no_db = init; eb_no_db <= final; eb_no_db += inc)
    {
      es_no = pow(10.0,(eb_no_db/10.0));   /* snr per bit */
      es_no = es_no*rate;                  /* snr per symbol */
      sum = Q(sqrt(2.0*es_no*d12));
      printf("%lf\t%e\n",eb_no_db,sum);
      fprintf(fp,"%lf\t%e\n",eb_no_db,sum);
    }
}


double Q(double a)
{
  double erfc( double x );
  return(0.5*erfc(a/sqrt(2.0)));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -