跪求无线中继误码率的C++编程 20C

自己编了很久结果还是错的,误码率都是大于0.5
比如说我采用32-QAM调制,固定AF协议,以下是我编写的程序:

for (i = 0; i < T; i++)
{
for (j = 0; j < T; j++)
{
H1[i][j] = complex(H1_re[i][j], H1_im[i][j]);
}//服从(0,1)分布
}

for (i = 0; i < T; i++)
{
    for (j = 0; j < T; j++)
    {
        H2[i][j] = complex<double>(H2_re[i][j], H2_im[i][j]);
    }//服从(0,1)分布
}

for (i = 0; i < T; i++)
{
    for (j = 0; j < 1; j++)
    {
        Y1[i][j] = complex<double>(receive_re[i], receive_im[i]);
    }
}
//cout<<Y<<endl;

for (i = 0; i < T; i++)
{
    N[0][0] = complex<double>(0.707*sqrt(sigma_2)*noise_re[i], 0.707*sqrt(sigma_2)*noise_im[i]);

}//服从(0,sigma_2)分布

G = 1 / double(sqrt(abs(H1[0][0])*abs(H1[0][0]) + sigma_2));
//cout << G << endl;
//cout << H1  << endl;
//cout << H2  << endl;

Y2 = G*Y1[0][0];
//cout << Y2 << endl;
//cout << Y1 << endl;

Y3 = H2*Y2 + N;
//cout <<Y3<< endl;
//cout << Y2 << endl;
//cout << N << endl;
//cout <<  h2_re[0]  << endl;

    for(j=0;j<M;j++)
    {
        S = complex<double>(s_re[j], s_im[j]);

        distance[j] = norm(Y3- H1[0][0]*H2[0][0]*G*S);
    }
    //cout <<  h1_re[0]  << endl;
    //cout << y3_re1[0] << endl;
    //cout << G << endl;
    //cout <<distance[0] << endl;
    //cout <<s_re[0] << endl;
    //cout <<s_im[0] << endl;

    index=0;
    min_dis=distance[0];
    for(j=0;j<M;j++)
    {
        if(j>0 && distance[j]<distance[index])
        {
            index=j;

        }

    }

    for(int d=0;d<L;d++)
    {
        x_msg_hat[d] = B[index][d];

    }

//cout << x_msg_hat[0] << endl;





其中G是放大因子,distance是求其最小汉明距离,采用的是硬判决译码。求大神帮忙看看,或者大神帮我编写无线中继误码率的C++程序,跪求啊!如果可以的话,可不可以把DF协议的程序也编出来~~DF的我也编了,误码率也是大于0.5,要崩溃了

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问