📄 chan_estimation.c
字号:
// estimation of the channel
// 2 functions: one to estimate the channel response, one to estimate the noise
// each time we update the value of h_hat and noise_hat
// we have to store alpha and beta, these values store the values of numerator and
// denominator.. each time we receive a pilot, we update alpha and beta and we
// compute the new value for H.
// Then there is an other function that estimates the noise power.
// I wrote some useful functions that i use here..
#include "receiver.h"
#include "chan_estimation.h"
#include "useful_functions.h"
#include <math.h>
#define SUBCARSIZE 124
float noise_hat; /* Value of the estimated noise */
/*
This funtion estimates the channel response
There are 3 inputs: _the pilots store at the receiver (as well as at the transmitter)
_the received pilots (pilots modified by the channel)
_the value of the forgetting factor
*/
void filter_estimation (const float *pilots, float *received_pilots,
float *pilots_prod, const float lambda, float *alpha, float *beta, float *h_hat, float *slask) {
int i;
float *crossprod=slask; //[2*SUBCARSIZE]; /* vector to hold crossprod betweeen actual & received pilots*/
// compute received_pilots.*conj(pilots)
prod_element_conj(pilots, received_pilots, crossprod, 2*SUBCARSIZE);
// update the values of alpha and beta
for (i=0; i<2*SUBCARSIZE ;i++){
alpha[i] = (1-lambda)*crossprod[i] + lambda*alpha[i];
beta[i] = (1-lambda)*pilots_prod[i] + lambda*beta[i];
}
// compute h_hat=alpha/beta;
div_element(alpha, beta, h_hat, 2*SUBCARSIZE);
}
/*
This funtion estimates the noise power
There is 1 input: _the received_empty pilots (zeros modified by the channel)
*/
float noise_estimation (short *received_empty_pilots)
{
//float absolute[SUBCARSIZE];
int j;
double noise_hat=0;
// square_absolute(received_empty_pilots, absolute, SUBCARSIZE);
for (j=0;j<SUBCARSIZE;j++) {
noise_hat += ((received_empty_pilots[j]*received_empty_pilots[j])+(received_empty_pilots[j+1]*received_empty_pilots[j+1]));
//noise_hat += (abs((int)received_empty_pilots[j])+abs((int)received_empty_pilots[j+1]));
// noise_hat += absolute[j]/SUBCARSIZE;
}
return (noise_hat/124);
}
/*
void main(){}
*/
float noise_estimate2(const float *pilots, const float *workbuffer, const float *h_hat)
{
int i;
float nre = 0;
float nim = 0;
for(i=0; i<124; i++)
{
nre += (workbuffer[2*i]-(h_hat[2*i]*pilots[2*i] - h_hat[2*i+1]*pilots[2*i+1]))*(workbuffer[2*i]-(h_hat[2*i]*pilots[2*i] - h_hat[2*i+1]*pilots[2*i+1]));
nim += (workbuffer[2*i+1]-(h_hat[2*i]*pilots[2*i+1] + h_hat[2*i+1]*pilots[2*i]))*(workbuffer[2*i+1]-(h_hat[2*i]*pilots[2*i+1] + h_hat[2*i+1]*pilots[2*i]));
}
return (nre+nim);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -