




下載本文檔
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上1.正態(tài)分布:#include <math.h> #include <stdlib.h> #include <time.h> #include <fstream> #include <iostream> using namespace std; #define pi 3. /Generate a randon number followed by uniform distribution between the inteval min,max template<typename T> T rand
2、(T min, T max) return min+(max-min)*rand()/(RAND_MAX+1.0); /calculate the normal density distribution 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
3、 sigma, double min ,double max) double x,y,dScope; do x=rand(min,max); y=normal(x,miu,sigma); dScope=rand(0.0,normal(miu,miu,sigma); while(dScope>y); return x; /Generate 10000 distributed random output numbers and put into a text called"123"int main(int argc,char* argv) double min,max,m
4、iu,sigma; srand(unsigned)time( NULL ); cin>>min>>max>>miu>>sigma; ofstream outfile("123.txt"); for (int i=0;i<10000;i+) outfile << randn(miu,sigma,min,max) << endl; return 0; 2.瑞利分布:#include <math.h> #include <stdio.h> #include <stdlib.
5、h> #include <time.h> #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 following generated random numbers double ruili(double sigma) Re
6、turn 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("input sigma:n"); scanf("%lf",&sigma)
7、; for (int i=0;i<10000;i+) FILE *fp;fp=fopen("321.txt","a+");fprintf(fp,"%lf,",ruili(sigma);printf("%lfn",randn();fclose(fp); return 0;3.泊松分布:#include<stdio.h>#include<stdlib.h>#include<ctime>#include<math.h>/Generate the random numb
8、erslong Possion(double u)double P,U;long N;u=exp(-u);P=1;N=0;while(1)U=(double)rand()/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; fp
9、1=fopen("p1.txt","w"); srand(unsigned)time(0); for(k=1;k<10000;k+) fprintf(fp1,"%6ld ",Possion(lamda); fclose(fp1); 4. Design a 128th order FIR band-pass digital filter with cut-off frequencies 10 MHz & 50 MHz Apply it to a signal, and display related filter and
10、signal waveforms.fc=1000; %載波頻率Êfc=1000HZqifs=280; %采樣頻率fs=280HZt=1:2:1000; x=sin(2*pi*t*fc); %generate signal waveforms.a=fir1(128,10 50/(qifs/2) ; %Bandpass butt.freqz (a,1) ; % plot gain & phase (the b array is 1 for FIR filter)y=filter(a,1, x); % FIR band-pass filter design. 5. Design a
11、 4th order IIR low-pass filter with fc = 100 Hz.Apply it to a signal, and display related filter and signal waveforms.fc =100; %載波頻率fc=100HZqifs=1000; %采樣頻率fs=1KHZt=(1:1000)/500; x=sin(2*pi*t*fc) %generate signal waveforms.a,b=butter(4, fc/(qifs/2) ) ; % lowpass Butt.freqz (a,b) ; % plot gain &
12、phase responses of digital filtersy=filter(a,b,x); % to implement6. Based on Program 2.3/2.4 of Ref.9 (by Yong Soo Cho, et al), investigate the impact of of the RMS delay spread and T s tothe channel frequency selectivity.% plot_IEEE80211_model.mclear, clfscale=1e-9; % nanoTs=100*scale; % Sampling t
13、imet_rms=250*scale; % RMS delay spreadnum_ch=10000; % Number of channelsN=128; % FFT sizePDP=IEEE802_11_model(t_rms,Ts); for k=1:length(PDP) h(:,k) = Ray_model(num_ch).'*sqrt(PDP(k); avg_pow_h(k)= mean(h(:,k).*conj(h(:,k);endH=fft(h(1,:),N);subplot(221)stem(0:length(PDP)-1,PDP,'ko'), hol
14、d on,stem(0:length(PDP)-1,avg_pow_h,'k.');xlabel('channel tap index, p'), ylabel('Average Channel Powerlinear');title('IEEE 802.11 Model, sigma_tau=25ns, T_S=25ns');legend('Ideal','Simulation'); axis(-1 7 0 1);subplot(222)plot(-N/2+1:N/2/N/Ts/106,10*lo
15、g10(H.*conj(H),'k-');xlabel('FrequencyMHz'), ylabel('Channel powerdB')title('Frequency response, sigma_tau=25ns, T_S=25ns');7. Simulate a BPSK communication system, comparing simulated with theoretical BER results under AWGN channel.clc;clear all;close all;num=;for SN
16、R=0:10 data_bpsk=randsrc(1,num,1,-1); snr=1/(10(SNR/10); noise=sqrt(snr/2)*(randn(1,num); receive=data_bpsk+noise; pe(SNR+1)=0; for(i=1:num) if (receive(i)>=0) r_data(i)=1; else r_data(i)=-1; end end pe(SNR+1)=(sum(abs(r_data-data_bpsk)/2)/num; peb(SNR+1)=0.5*erfc(sqrt(10(SNR/10);endr=0:10;semilo
17、gy(r,peb,'b-v',r,pe,'m-x');%對(duì)y取底為10對(duì)數(shù)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 for each EbNo% QPSK System Simulation, Pe evaluationc
18、lear;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(10)/10); % signal to noise ratio theo_err_prb(i)=0.5
19、*erfc(sqrt(SNR); % theoretical bit error rate echo off;end;% Plotting commands follow %作圖grid onsemilogy(SNRindB1,smld_bit_err_prb,'*'); % 用對(duì)數(shù)坐標(biāo)作出仿真信噪比-誤比特率的點(diǎn)hold onsemilogy(SNRindB2,theo_err_prb); %用對(duì)數(shù)坐標(biāo)作出理論信噪比-誤比特率曲線hold onxlabel('信噪比(dB)');ylabel('誤碼率');legend('bit err
20、or probability','theory error probability');title('BER performance of QPSK transmission scheme under AWGN channel');function pb,ps=cm_sm32(snr_in_dB)% pb,ps=cm_sm32(snr_in_dB)% CM_SM3 finds the probability of bit error and symbol error for % the given value of snr_in_dB, signal t
21、o noise ratio in dB.N=10000;E=1; % energy per symbolsnr=10(snr_in_dB/10); % signal to noise ratiosgma=sqrt(E/snr)/2; % noise variances00=1 0; s01=0 1; s11=-1 0; s10=0 -1; % signal mapping% generation of the data source, QPSK modulationfor i=1:N, temp=rand; % a uniform random variable between 0 and 1
22、 if (temp<0.25), % with probability 1/4, source output is "00" dsource1(i)=0; dsource2(i)=0; elseif (temp<0.5), % with probability 1/4, source output is "01" dsource1(i)=0; dsource2(i)=1; elseif (temp<0.75), % with probability 1/4, source output is "10" dsource
23、1(i)=1; dsource2(i)=0; else % with probability 1/4, source output is "11" dsource1(i)=1; dsource2(i)=1; end;end;% detection and the probability of error calculationnumofsymbolerror=0;numofbiterror=0;% go through AWGN channelfor i=1:N, % the received signal at the detection, for the ith sym
24、bol,is: n=sgma*randn(1,2); % 2 normal distributed r.v with 0, variance sgma if (dsource1(i)=0) & (dsource2(i)=0), r=s00+n; elseif (dsource1(i)=0) & (dsource2(i)=1), r=s01+n; elseif (dsource1(i)=1) & (dsource2(i)=0), r=s10+n; else r=s11+n; end; % The correlation metrics are computed below
25、 c00=dot(r,s00); c01=dot(r,s01); c10=dot(r,s10); c11=dot(r,s11); % The decision on the ith symbol is made next c_max=max(c00,c01,c10,c11);% The decision on the ith symbol, MLD if (c00=c_max), decis1=0; decis2=0; elseif (c01=c_max), decis1=0; decis2=1; elseif (c10=c_max), decis1=1; decis2=0; else dec
26、is1=1; decis2=1; end;% Later, increment the error counter, if the decision is not correct, % Increment the error counter, if the decision is not correct symbolerror=0; if (decis1=dsource1(i), numofbiterror=numofbiterror+1; symbolerror=1; end; if (decis2=dsource2(i), numofbiterror=numofbiterror+1; sy
27、mbolerror=1; end; if (symbolerror=1), numofsymbolerror=numofsymbolerror+1; end;end;ps=numofsymbolerror/N; % since there are totally N symbolspb=numofbiterror/(2*N); % since 2N bits are transmitted9. Simulate the error performance of an 8-QAM system using the built-in Matlab channel function " rayleighchan ".% 8QAM System Simulation, Pe evaluation M=8; % QAM 調(diào)制階數(shù) k = log2(M); hMod=comm.RectangularQAMModulator(M); % 產(chǎn)生 8 QAM 信號(hào)調(diào)制器 display(hMod); txd = randint(1e4,1,M); %產(chǎn)生1,M范圍的均勻分布的隨機(jī)序列,用于在接收端發(fā)送基帶信號(hào) qamSig = step(hMod,
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司福利院慰問(wèn)活動(dòng)方案
- 公司福利團(tuán)建旅游活動(dòng)方案
- 公司自駕游出行活動(dòng)方案
- 2025年職業(yè)生涯規(guī)劃與發(fā)展考試試卷及答案
- 2025年應(yīng)急救援與災(zāi)難管理考試題及答案
- 2025年新興技術(shù)與傳統(tǒng)行業(yè)融合發(fā)展的能力測(cè)試試卷及答案
- 2025年水資源管理與可持續(xù)發(fā)展考試題及答案
- 2025年生物醫(yī)學(xué)工程專(zhuān)業(yè)綜合考試試題及答案
- 2025年農(nóng)田水利工程師職業(yè)資格考試試卷及答案
- 2025年量子物理基礎(chǔ)知識(shí)與應(yīng)用考試試題及答案
- GB/T 43988-2024滑板課程學(xué)生運(yùn)動(dòng)能力測(cè)評(píng)規(guī)范
- DL-T1069-2016架空輸電線路導(dǎo)地線補(bǔ)修導(dǎo)則
- 江蘇開(kāi)放大學(xué)本科行政管理專(zhuān)業(yè)060193國(guó)家公務(wù)員制度期末試卷
- 山東省青島市嶗山區(qū)育才學(xué)校2023-2024學(xué)年下學(xué)期奇點(diǎn)計(jì)劃選拔考試八年級(jí)物理試卷
- MOOC 基礎(chǔ)工程設(shè)計(jì)原理-同濟(jì)大學(xué) 中國(guó)大學(xué)慕課答案
- 哈密市伊吾縣社工招聘筆試真題
- 紡織非遺:讓世界讀懂中國(guó)之美智慧樹(shù)知到期末考試答案2024年
- 應(yīng)急處突知識(shí)培訓(xùn)課件
- JB T 8925-2008滾動(dòng)軸承汽車(chē)萬(wàn)向節(jié)十字軸總成技術(shù)條件
- 感悟《亮劍》中的營(yíng)銷(xiāo)啟示課件
- 八年級(jí)歷史下冊(cè) 期末考試卷(人教版)(一)
評(píng)論
0/150
提交評(píng)論