版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、%*% This function pertains to the addition of AWGN with mean zero and % parameter variance to an input signal. % AUTHOR: Wenbin Luo% DATE : 04/12/01% SYNOPSIS: y = awgn(x,var)% x - input signal% var - variance% y - y = x + AWGN %*function y = awgn(x,var) w = randn(1,length(x); w = w - mean(w)*ones(s
2、ize(w); w = sqrt(var)*(w / std(w); x = x(:); w = w(:); y = x + w; %*% This function does the DS-SS modulation% AUTHOR: Wenbin Luo% DATE : 04/28/01% SYNOPSIS: y = ds_mod(c,x)% c - user code (column vector)% x - input signal (row vector)% y - tmp = c*x, y = tmp(:) (ds-ss modulated signal, column vecto
3、r)%*function y = ds_mod(c,x)tmp = c*x;y = tmp(:);%*% This function generates random +1/-1 sequence with independent identically % distributed symbols% AUTHOR: Wenbin Luo% DATE : 04/28/01% SYNOPSIS: x = bingen(L)% L - number of random symbols %*function x = bingen(L)%generate L symbols randomly with
4、value +1 or -1x = rand(1,L);x(find(x=) = 1;%*% This function does the DS-SS modulation% AUTHOR: Wenbin Luo% DATE : 04/28/01% SYNOPSIS: x = ds_demod(c,y)% c - user code (column vector)% y - tmp = c*x, y = tmp(:) (ds-ss modulated signal, column vector)% x - input signal (row vector)%*function x = ds_d
5、emod(c,y)tmp = reshape(y, length(c), length(y)/length(c);tmp = tmp;%x is a column vectorx = tmp * c;% convert to row vectorx = x;%*% This function does the DS-SS modulation% AUTHOR: Wenbin Luo% DATE : 04/28/01% SYNOPSIS: y = ds_mod(c,x)% c - user code (column vector)% x - input signal (row vector)%
6、y - tmp = c*x, y = tmp(:) (ds-ss modulated signal, column vector)%*function y = ds_mod(c,x)tmp = c*x;y = tmp(:);%*% This mfunction generates faded envelope and phase % corresponding to Rayleigh fading% AUTHOR: Wenbin Luo% DATE : 04/27/01% FUNCTION SYNOPSIS: % env,phi = fade(L,para)% % Parameter Desc
7、ription: % L : number of samples needed % variance : variance %*function env,phi = fade(L,variance)% Error checkif variance = 0 error(Positive variance needed)elseif nargin = 2 error(Insufficient input parameters)end% Generate bivariate Gaussian uncorrelated % random variablesmu = zeros(1,2);C = var
8、iance*eye(2,2);r = mvnrnd(mu,C,L);% Convert to polar coordinates and compute % magnitude and phase z = r(:,1) + j*r(:,2);env = abs(z); phi = angle(z);%*%*% This mfunction generates two channels of faded % envelope and phase corresponding to% Rayleigh fading% AUTHOR: Wenbin Luo% DATE : 04/27/01% FUNC
9、TION SYNOPSIS: % env,phi = fade_diversity(L,para)% % Parameter Description: % L : number of samples needed % variance : variance %*function env1,env2 = fade_diversity(L,variance)% Error checkif variance = 0 error(Positive variance needed)elseif nargin = 2 error(Insufficient input parameters)end% Gen
10、erate bivariate Gaussian uncorrelated % random variablesmu = zeros(1,4);C = variance*eye(4,4);r = mvnrnd(mu,C,L);% Convert to polar coordinates and compute % magnitude and phase z1 = r(:,1) + j*r(:,2);z2 = r(:,3) + j*r(:,4);env1 = abs(z1); env2 = abs(z2);%*%*% This mfunction generates frequency sele
11、ctive % Rayleigh fading% AUTHOR: Wenbin Luo% DATE : 05/02/01% FUNCTION SYNOPSIS: % y = fade_fs(x,L)% % Parameter Description: %y : output signal% x : input signal % L : number of independent Rayleigh %fading process %*function y = fade_fs(x,L)% Generate bivariate Gaussian uncorrelated % random varia
12、blestmp1 = 0:1:(L-1);tmp1 = exp(-tmp1);tmp(1:2:2*L-1) = tmp1;tmp(2:2:2*L) = tmp1;mu = zeros(1,2*L);C = *diag(tmp);x_len = length(x);r = mvnrnd(mu,C,x_len);% Convert to polar coordinates and compute magnitudex = x(:);y = zeros(x_len,1);for i = 1:L, z = r(:,2*i-1) + j*r(:,2*i); env = abs(z); %phi = an
13、gle(z); tmp_y = env.*x; tmp_y = zeros(i-1,1); tmp_y(1:x_len-i+1); y = y + tmp_y;end%*%*% This program computes the average BER of a DS-SS/BPSK %communication system with binary BCH code in the AWGN channel% % AUTHOR: Wenbin Luo% DATE : 04/28/01% %*%function Plot_Pe = final11_extra()clear all;%close
14、all;format long;%set up the threshold Vt Vt = 0;Plot_Pe = ;N = 16;x_num = 2500;plot_EbNo = -20:2:10;for EbNo = -20:2:10, %convert back from dBEb_No = EbNo; %dBEb_No = 10.(Eb_No/10);%assume No = 2;No = 2;Eb = No * Eb_No;%calculate power pTc = 1;Ts = N * Tc;p = Eb / Ts;%generate BPSK symbols randomly
15、with value +1 or -1x = bingen(x_num);x_org = x;%adds error-correcting codeenc_N = 15; enc_K = 5; %7/4 or 15/5x(find(x 0) = 0;x = encode(x,enc_N,enc_K,bch);x = x;x(find(x = 0) = -1;%DS-SS modulate symbols with user codec = bingen(N);y = ds_mod(c(:),x);%scale by appropriate power factory = sqrt(p)*y;%
16、add AWGN to signaly = awgn(y,1);%DS-SS demodulate symbols with user codex_de = ds_demod(c(:),y);%decisionx_de(find(x_de =0) = 1;%decode error-correcting codex_de(find(x_de 0) = 0;x_de = decode(x_de,enc_N,enc_K,bch);x_de = x_de;x_de(find(x_de = 0) = -1;%-Pe = length(find(x_org - x_de)/x_num;Plot_Pe =
17、 Plot_Pe Pe;end %end for EbNo%-%return;%-%display the calculated Pd and PfaPlot_Pe%plot Pe versus Eb/Nosemilogy(plot_EbNo,Plot_Pe,bo-)xlabel(Eb/No (dB)ylabel(BER)s=sprintf(BER versus Eb/No with binary BCH code in the AWGN channel);title(s);%*% This program computes the average BER of a DS-SS/BPSK %c
18、ommunication system with binary BCH code in the AWGN channel% % AUTHOR: Wenbin Luo% DATE : 04/28/01% %*%function Plot_Pe = final11_extra()clear all;%close all;format long;%set up the threshold Vt Vt = 0;Plot_Pe = ;N = 16;x_num = 2500;plot_EbNo = -20:2:10;for EbNo = -20:2:10, %convert back from dBEb_
19、No = EbNo; %dBEb_No = 10.(Eb_No/10);%assume No = 2;No = 2;Eb = No * Eb_No;%calculate power pTc = 1;Ts = N * Tc;p = Eb / Ts;%generate BPSK symbols randomly with value +1 or -1x = bingen(x_num);x_org = x;%adds error-correcting codeenc_N = 15; enc_K = 5; %7/4 or 15/5x(find(x 0) = 0;x = encode(x,enc_N,e
20、nc_K,bch);x = x;x(find(x = 0) = -1;%DS-SS modulate symbols with user codec = bingen(N);y = ds_mod(c(:),x);%scale by appropriate power factory = sqrt(p)*y;%add AWGN to signaly = awgn(y,1);%DS-SS demodulate symbols with user codex_de = ds_demod(c(:),y);%decisionx_de(find(x_de =0) = 1;%decode error-cor
21、recting codex_de(find(x_de 0) = 0;x_de = decode(x_de,enc_N,enc_K,bch);x_de = x_de;x_de(find(x_de = 0) = -1;%-Pe = length(find(x_org - x_de)/x_num;Plot_Pe = Plot_Pe Pe;end %end for EbNo%-%return;%-%display the calculated Pd and PfaPlot_Pe%plot Pe versus Eb/Nosemilogy(plot_EbNo,Plot_Pe,bo-)xlabel(Eb/N
22、o (dB)ylabel(BER)s=sprintf(BER versus Eb/No with binary BCH code in the AWGN channel);title(s);%*% This program computes the average BER of a DS-SS/BPSK %communication system with binary BCH code in the AWGN channel% % AUTHOR: Wenbin Luo% DATE : 04/28/01% %*%function Plot_Pe = final11_extra()clear a
23、ll;%close all;format long;%set up the threshold Vt Vt = 0;Plot_Pe = ;N = 16;x_num = 2500;plot_EbNo = -20:2:10;for EbNo = -20:2:10, %convert back from dBEb_No = EbNo; %dBEb_No = 10.(Eb_No/10);%assume No = 2;No = 2;Eb = No * Eb_No;%calculate power pTc = 1;Ts = N * Tc;p = Eb / Ts;%generate BPSK symbols
24、 randomly with value +1 or -1x = bingen(x_num);x_org = x;%adds error-correcting codeenc_N = 15; enc_K = 5; %7/4 or 15/5x(find(x 0) = 0;x = encode(x,enc_N,enc_K,bch);x = x;x(find(x = 0) = -1;%DS-SS modulate symbols with user codec = bingen(N);y = ds_mod(c(:),x);%scale by appropriate power factory = s
25、qrt(p)*y;%add AWGN to signaly = awgn(y,1);%DS-SS demodulate symbols with user codex_de = ds_demod(c(:),y);%decisionx_de(find(x_de =0) = 1;%decode error-correcting codex_de(find(x_de 0) = 0;x_de = decode(x_de,enc_N,enc_K,bch);x_de = x_de;x_de(find(x_de = 0) = -1;%-Pe = length(find(x_org - x_de)/x_num
26、;Plot_Pe = Plot_Pe Pe;end %end for EbNo%-%return;%-%display the calculated Pd and PfaPlot_Pe%plot Pe versus Eb/Nosemilogy(plot_EbNo,Plot_Pe,bo-)xlabel(Eb/No (dB)ylabel(BER)s=sprintf(BER versus Eb/No with binary BCH code in the AWGN channel);title(s);%*% This program computes the average BER of a DS-
27、SS/BPSK %communication system in the presence of pulsed noise jamming%and AWGN% % AUTHOR: Wenbin Luo% DATE : 04/28/01% %*%function Plot_Pe = final12()clear all;%close all;format long;%set up the threshold Vt Vt = 0;Plot_Pe = ;N = 16;ro = ; %1, , x_num = 10000;plot_EbNo = -20:2:10; for EbNo = -20:2:1
28、0, %convert back from dBEb_No = EbNo; %dBEb_No = 10.(Eb_No/10);%assume No = 2;No = 2;Eb = No * Eb_No;%calculate power pTc = 1;Ts = N * Tc;p = Eb / Ts;%generate BPSK symbols randomly with value +1 or -1x = bingen(x_num);%DS-SS modulate symbols with user codec = bingen(N);y = ds_mod(c(:),x);%scale by
29、appropriate power factory = sqrt(p)*y;%add Pulsed Noise Jammer to signaly = awgn(y(1:ro*length(y),1/ro); y(ro*length(y)+1):length(y);%DS-SS demodulate symbols with user codex_de = ds_demod(c(:),y);%decisionx_de(find(x_de =0) = 1;Pe = length(find(x - x_de)/x_num;Plot_Pe = Plot_Pe Pe;end %end for EbNo
30、%-%return;%-%display the calculated Pd and PfaPlot_Pe%plot Pe versus Eb/No%subplot(2,1,1)semilogy(plot_EbNo,Plot_Pe,m*-)xlabel(10log_10(P/J)(W/R) (dB)ylabel(BER)s=sprintf(BER versus 10log_10(P/J)(W/R) in pulsed noise jamming and AWGN);title(s);%*% This program computes the average BER of a DS-SS/BPS
31、K %communication system in barrage noise jamming and AWGN% % AUTHOR: Wenbin Luo% DATE : 05/02/01% %*% function Plot_Pe = final12_extra()clear all;%close all;format long;%set up the threshold Vt Vt = 0;Plot_Pe = ;N = 16;x_num = 10000;%-%convert back from dBEb_No = 5; % 2, 4, 6 dB Eb_No = 10.(Eb_No/10
32、);%assume No = 2;No = 2;Eb = No * Eb_No;%calculate power pTc = 1;Ts = N * Tc;p = Eb / Ts;%-plot_EbNj = 0:2:50; for EbNj = 0:2:50, %convert back from dBEb_Nj = EbNj; %dBEb_Nj = 10.(Eb_Nj/10);Nj = Eb / Eb_Nj; %generate BPSK symbols randomly with value +1 or -1x = bingen(x_num);%DS-SS modulate symbols
33、with user codec = bingen(N);y = ds_mod(c(:),x);%scale by appropriate power factory = sqrt(p)*y;%add barrage noise jamming and AWGN to signaly = awgn(y,(Nj/2)+1);%y = awgn(y,1);%DS-SS demodulate symbols with user codex_de = ds_demod(c(:),y);%decisionx_de(find(x_de =0) = 1;Pe = length(find(x - x_de)/x
34、_num;Plot_Pe = Plot_Pe Pe;end %end for EbNo%-%return;%-%display the calculated Pd and PfaPlot_Pe%plot Pe versus Eb/No%subplot(2,1,1)semilogy(plot_EbNj,Plot_Pe,m*-)xlabel(10log_10(P/J)(W/R) (dB)ylabel(BER)s=sprintf(BER versus 10log_10(P/J)(W/R) in barrage noise jamming and AWGN);title(s);grid on;%*%
35、This program computes the average BER in Rayleigh fading %and AWGN% % AUTHOR: Wenbin Luo% DATE : 04/28/01% %*%function Plot_Pe = final21()clear all;%close all;format long;%set up the threshold Vt Vt = 0;Plot_Pe = ;N = 16;x_num = 10000;plot_EbNo = -30:2:30; %-20:2:10;for EbNo = -30:2:30, %convert bac
36、k from dBEb_No = EbNo; %dBEb_No = 10.(Eb_No/10);%assume No = 2;No = 2;Eb = No * Eb_No;%calculate power pTc = 1;Ts = N * Tc;p = Eb / Ts;%generate BPSK symbols randomly with value +1 or -1x = bingen(x_num);x_original = x;x = sqrt(p)*x;%generate Rayleigh fadingenv,phi = fade(length(x),;%generate faded
37、sequencex = env.*x;x = x;%DS-SS modulate symbols with user codec = bingen(N);y = ds_mod(c(:),x);%scale by appropriate power factor%y = sqrt(p)*y;%add AWGN to signaly = awgn(y,1);%DS-SS demodulate symbols with user codex_de = ds_demod(c(:),y);%decisionx_de(find(x_de =0) = 1;Pe = length(find(x_origina
38、l - x_de)/x_num;Plot_Pe = Plot_Pe Pe;end %end for EbNo%-%return;%-%display the calculated Pd and PfaPlot_Pe%plot Pe versus Eb/No%subplot(2,1,1)semilogy(plot_EbNo,Plot_Pe,r-)xlabel(Eb/No (dB)ylabel(BER)s=sprintf(BER versus Eb/No in Rayleigh fading and AWGN);title(s);grid on;%*% This program simulates
39、 a predetection selective combining%receiver for a Rayleigh fading channel % % AUTHOR: Wenbin Luo% DATE : 04/28/01% %*clear all;%close all;format long;%set up the threshold Vt Vt = 0;Plot_Pe = ;N = 16;x_num = 10000;plot_EbNo = -30:2:20; %-20:2:10;for EbNo = -30:2:20, %convert back from dBEb_No = EbN
40、o; %dBEb_No = 10.(Eb_No/10);%assume No = 2;No = 2;Eb = No * Eb_No;%calculate power pTc = 1;Ts = N * Tc;p = Eb / Ts;%generate BPSK symbols randomly with value +1 or -1x = bingen(x_num);x_original = x;x = sqrt(p)*x;%generate Rayleigh fadingenv1,env2 = fade_diversity(length(x),;%generate faded sequence
41、x_fad1 = env1.*x;x_fad1 = x_fad1;x_fad2 = env2.*x;x_fad2 = x_fad2;%DS-SS modulate symbols with user codec = bingen(N);y_fad1 = ds_mod(c(:),x_fad1);y_fad2 = ds_mod(c(:),x_fad2);%scale by appropriate power factor%y = sqrt(p)*y;%add AWGN to signaly_fad1 = awgn(y_fad1,1);y_fad2 = awgn(y_fad2,1);%DS-SS demodulate symbols
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 滴水穿石啟示讀后感7篇
- 技術(shù)工作計劃
- 植樹節(jié)課件博客
- 新人婚禮儀式開場主持詞范文
- 洗衣房上半年工作總結(jié)
- 垃圾分類的教案
- 慰問老人的發(fā)言稿400字(5篇)
- 高中生職業(yè)規(guī)劃范文(5篇)
- 2024屆浙江省臺州市椒江區(qū)第一中學高三2月七校聯(lián)考數(shù)學試題
- 人教版七年級數(shù)學上冊《4.3.3余角和補角》課后練習
- 燃氣管道-流量-流速-口徑計算公式
- 華電架空輸電線路大作業(yè)
- 暗挖工程冬季施工措施
- 往生薦亡功德文疏
- 2021年春新教科版四年級下冊科學 2.3《簡易電路》教案含教學反思
- 相干反斯托克斯拉曼光譜cars-姚波善
- GB∕T 13331-2014 土方機械 液壓挖掘機 起重量
- (畢業(yè)論文)烷基化裝置危險性分析
- 赫爾曼的敘事學理論
- 醫(yī)學德語詞匯大全
- 化學品安全標簽編寫規(guī)定_GB15258-2009
評論
0/150
提交評論