基于Matlab 的 OFDM 调制解调系统仿真实验




请查阅下面的引用文档,文档本身更加注重ofdm 的原理讲解,并没有大量的罗列公式,这样更加方便理解ofdm原理
https://wenku.baidu.com/view/bbb6ba9d00f69e3143323968011ca300a7c3f6cc?fr=text_ernie_recall_backup%3Awk_recommend_main3-TopList_highScoreList-pcview_toplistrec_highscore_wk_recommend_main3-b2d4684bb4360b4c2e3f5727a5e9856a56122627&_wkts_=1680250929544&bdQuery=matlab+ofdm

ofdm 中用到的信号:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.1415926536
#define Num 1048576
#define bit 2


double AWGN_generator(double x , int db)
{/* Generates additive white Gaussian Noise samples with zero mean and a standard deviation of 1. */
    
    double temp1;
    double temp2;
    double result;
    double sigma = 0;
    int p;
    
    p = 1;
    
    while( p > 0 )
    {
        temp2 = ( rand() / ( (double)RAND_MAX ) ); /*  rand() function generates an
                                                    integer between 0 and  RAND_MAX,
                                                    which is defined in stdlib.h.
                                                    */
        
        if ( temp2 == 0 )
        {// temp2 is >= (RAND_MAX / 2)
            p = 1;
        }// end if
        else
        {// temp2 is < (RAND_MAX / 2)
            p = -1;
        }// end else
        
    }// end while()
    
    temp1 = cos( ( 2.0 * (double)PI ) * rand() / ( (double)RAND_MAX ) );
    sigma = sqrt(1/(64 * pow(10 ,((double) db / 10) )));
    result = sigma / 2 * sqrt( -2.0 * log( temp2 ) ) * temp1;
    
    return result;	// return the generated random sample to the caller
    
}// end AWGN_generator()

int main(int argc, const char * argv[]) {
    // insert code here...
    if ( argc != 4 )  //argc should be 2 for correct execution
    {
        //We print argv[0] assuming it is the program name
        printf( "need 3 arguments\n");
        printf( "1st is this prgram, 2rd is input data filename, 3nd is the output filename.  4th is db\n");
        exit(1);
    }
    int db = atoi(argv[3]);
    double *x_Re, *x_Im;
    x_Re=malloc(sizeof(double)* ((Num/bit/64)*80));
    x_Im=malloc(sizeof(double)* ((Num/bit/64)*80));
    
    FILE *fin  = fopen(argv[1], "r"); // read only
    FILE *fout = fopen(argv[2], "w"); //write only
    // test for files not existing.
    if (fin == NULL)
    {
        printf("Error! Could not open file\n");
        exit(-1); // must include stdlib.h
    }
    
    for (int i = 0; i < ((Num/bit/64)*80); i++)
    {
        fscanf(fin,"%lf%lf",&x_Re[i],&x_Im[i]);
        //printf("\t%15f\t%15f\n",x_Re[i],x_Im[i]);
    }
    
    for (int j = 0; j < ((Num/bit/64)*80); j ++) {
            fprintf(fout,"%15f\t%15f\n",x_Re[j] + AWGN_generator(x_Re[j], db),x_Im[j] + AWGN_generator(x_Im[j], db));
        
    }
    
    fclose(fin);
    fclose(fout);
    
    return 0;
}

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值