通信建模作业程序集锦(共5页).docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《通信建模作业程序集锦(共5页).docx》由会员分享,可在线阅读,更多相关《通信建模作业程序集锦(共5页).docx(5页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上1.正态分布:#include #include #include #include #include using namespace std; #define pi 3. /Generate a randon number followed by uniform distribution between the inteval min,max template T rand(T min, T max) return min+(max-min)*rand()/(RAND_MAX+1.0); /calculate the normal density distribut
2、ion values double normal(double x, double miu,double sigma) return 1.0/sqrt(2*pi)/sigma*exp(-1*(x-miu)*(x-miu)/(2*sigma*sigma); /Generate a distributed random output numberdouble randn(double miu,double sigma, double min ,double max) double x,y,dScope; do x=rand(min,max); y=normal(x,miu,sigma); dSco
3、pe=rand(0.0,normal(miu,miu,sigma); while(dScopey); return x; /Generate 10000 distributed random output numbers and put into a text called123int main(int argc,char* argv) double min,max,miu,sigma; srand(unsigned)time( NULL ); cinminmaxmiusigma; ofstream outfile(123.txt); for (int i=0;i10000;i+) outfi
4、le randn(miu,sigma,min,max) endl; return 0; 2.瑞利分布:#include #include #include #include #define pi 3./ generate the random numbers between the interval 0,1double randn()double f;f = (double)(rand()%1001); /0,1000return f/1000.0; /0,1/calculate the Rayleigh density function values by using the followi
5、ng generated random numbers double ruili(double sigma) Return randn()/(sigma*sigma)*exp(-randn()*randn()/(2*sigma*sigma); /The main function can generate 10000 distributed random output numbers which are put into a text called”321”int main(void) double sigma; srand(unsigned)time( NULL ); printf(inpu
6、t sigma:n); scanf(%lf,&sigma); for (int i=0;i10000;i+) FILE *fp;fp=fopen(321.txt,a+);fprintf(fp,%lf,ruili(sigma);printf(%lfn,randn();fclose(fp); return 0;3.泊松分布:#include#include#include#include/Generate the random numberslong Possion(double u)double P,U;long N;u=exp(-u);P=1;N=0;while(1)U=(double)ran
7、d()/RAND_MAX;P=P*U;if(P=u) break;N+;return N;/ Generate 10000 distributed random output numbers which are put into a text called”312”void main() int k; double lamda; scanf(%lf,&lamda); FILE *fp1; fp1=fopen(p1.txt,w); srand(unsigned)time(0); for(k=1;k=0) r_data(i)=1; else r_data(i)=-1; end end pe(SNR
8、+1)=(sum(abs(r_data-data_bpsk)/2)/num; peb(SNR+1)=0.5*erfc(sqrt(10(SNR/10);endr=0:10;semilogy(r,peb,b-v,r,pe,m-x);%对y取底为10对数grid on;legend(理论误码率曲线,仿真误码率曲线);8. Simulate the error performance of a QPSK system using Quasi-analytical method, under AWGN channel. At least 200 errors should be generated fo
9、r each EbNo% QPSK System Simulation, Pe evaluationclear;clc;SNRindB1=0:0.05:10; %仿真信噪比范围SNRindB2=0:0.1:10; %理论信噪比范围for i=1:length(SNRindB1), pb=cm_sm32(SNRindB1(i); % simulated bit error rates smld_bit_err_prb(i)=pb; disp(pb); echo off;end;%echo on;For i=1:length(SNRindB2), SNR=exp(SNRindB2(i)*log(1
10、0)/10); % signal to noise ratio theo_err_prb(i)=0.5*erfc(sqrt(SNR); % theoretical bit error rate echo off;end;% Plotting commands follow %作图grid onsemilogy(SNRindB1,smld_bit_err_prb,*); % 用对数坐标作出仿真信噪比-误比特率的点hold onsemilogy(SNRindB2,theo_err_prb); %用对数坐标作出理论信噪比-误比特率曲线hold onxlabel(信噪比(dB);ylabel(误码率)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 通信 建模 作业 程序 集锦
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内