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

📄 runrayleigh.cpp

📁 Rayleigh 信道的matlab 仿真程序 及论文"A Fast and Accurate Rayleigh Fading Simulator"
💻 CPP
字号:
#include <iostream.h>
#include <stdio.h>
#include <math.h>
#include <fstream.h>
#include <string.h>
#include "Complex.h"
#include "Random.h"
#include "flat_rayleigh.h"

main(int argc, char *argv[])
{
  const int blocklength = 4000;
  const int maxblocks = 100;
  const double fD = 0.01;

  char logfile[35];

  if (argc == 3)
    sprintf(logfile, argv[2]);
  else {
    sprintf(logfile, "logR%.3f.txt", fD);
  }
  
  // construct it: seed, discrete Doppler fD, pwr=1.0, and continuous
  long seed = -115;
  flat_rayleigh mychan(seed, fD, 1.0, false);

  int i, blocknum;

  Complex inp[blocklength], outp[blocklength];  

  for (i=0; i<blocklength; i++)
	  inp[i] = Complex(1.0, 0.0);
  // If you want to run it on the background,
  // just comment out the following three lines.
  cout << "***********************************\n";
  cout << "************   BEGIN   ************\n";
  cout << "***********************************\n";
  for (blocknum = 1; blocknum<=maxblocks; blocknum++) {
	mychan.pass_through(blocklength, inp, outp);
    ofstream out(logfile, ios::app);
    if (!out)
		cout << "Sorry, I cannot write on the output file\n";
	else {
		for (i=0; i<blocklength; i++)
			out << i << "\t" << outp[i] << endl;
    }
	out.close();
  }
  return 0;
}

⌨️ 快捷键说明

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