📄 chanawgn.cpp
字号:
#include "parameter_sets.h"
#include "wuzhanji_random.h"
const double MAX = RAND_MAX;
const double Pi = 3.141592653589793; //From Matlab 2006R
const double sqrt2 = 1.414213562373095; //From Matlab 2006R
struct Complex * ChanAwgnF(struct BasicParaS * ctrl, struct Complex * input, double Eb_No_dB)
{
// insert the Gauss channel here ..
int i, temp;
double sigma,sigma2;
if (ctrl->noiseMode == 0) { // Eb/No
sigma = 1/sqrt(ctrl->r*pow(10.0, Eb_No_dB/10));
} else { // SNR
sigma = 1/(2* pow(10.0, -Eb_No_dB/10));
}
sigma2=sigma*sigma;
for (i=0; i<ctrl->numSymOut; i++) {
// Using Box-Muller Transform
if (ctrl->typeModu == 0)
(*(input+i)).real += AWGN(sigma2);
else {
(*(input+i)).real += AWGN(sigma2)/sqrt2;
(*(input+i)).imag += AWGN(sigma2)/sqrt2;
}
}
temp = 0;
if (ctrl->mode == 1) {
printf("The symbols undergo the AWGN ..\n");
temp = 0;
for (i=0; i<ctrl->numSymOut; i++) {
printf(" %.3f+j%.3f", (*(input+i)).real, (*(input+i)).imag);
temp++;
if (temp == 4) {
printf("\n");
temp = 0;
}
}
}
return input;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -