




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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)*on
2、es(size(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 v
3、ector)%*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 w
4、ith value +1 or -1x = rand(1,L);x(find(x=0.5) = 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
5、 = ds_demod(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 ve
6、ctor)% 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)% % Paramet
7、er Description: % 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);
8、C = variance*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/0
9、1% FUNCTION 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)e
10、nd% Generate 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 frequen
11、cy selective % 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 % rando
12、m variablestmp1 = 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 = 0.5*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);
13、 %phi = angle(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%final11_extra.m% %*%function Plot_Pe = final1
14、1_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_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;%gener
15、ate 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,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 p
16、ower 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-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_o
17、rg - 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/No (dB)ylabel(BER)s=sprintf(BER versus Eb/No with binary BCH code in the AWGN channel);title(s);%*% This program computes the aver
18、age BER of a DS-SS/BPSK %communication system with binary BCH code in the AWGN channel% % AUTHOR: Wenbin Luo% DATE : 04/28/01%final11_extra.m% %*%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
19、 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 with value +1 or -1x = bingen(x_num);x_org = x;%adds error-correcting codeenc_N = 15; enc_K = 5; %7/4 o
20、r 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;%add AWGN to signaly = awgn(y,1);%DS-SS demodulate symbols with user codex_de = ds_demod(c(:),y);%decisi
21、onx_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 = Plot_Pe Pe;end %end for EbNo%-%return;%-%display the calculated Pd and PfaPlot_Pe%plot Pe versus Eb/No
22、semilogy(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 %communication system with binary BCH code in the AWGN channel% % AUTHOR: Wenbin Luo% DATE : 04/28/01%fin
23、al11_extra.m% %*%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_No = EbNo; %dBEb_No = 10.(Eb_No/10);%assume No = 2;No = 2;Eb = No * Eb_No;%calculate po
24、wer 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,enc_K,bch);x = x;x(find(x = 0) = -1;%DS-SS modulate symbols with user codec = bingen(N);
25、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-correcting codex_de(find(x_de 0) = 0;x_de = decode(x_de,enc_N,enc_K,bch);x_de = x_de;x_de(
26、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/No (dB)ylabel(BER)s=sprintf(BER versus Eb/No with binary BCH code in the AWGN channel);t
27、itle(s);%*% This program computes the average BER of a DS-SS/BPSK %communication system in the presence of pulsed noise jamming%and AWGN% % AUTHOR: Wenbin Luo% DATE : 04/28/01%final12.m% %*%function Plot_Pe = final12()clear all;%close all;format long;%set up the threshold Vt Vt = 0;Plot_Pe = ;N = 16
28、;ro = 0.2; %1, 0.4, 0.2x_num = 10000;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 with value +1 or -1x = bingen(x_num);%DS-
29、SS modulate symbols with user codec = bingen(N);y = ds_mod(c(:),x);%scale by 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
30、) = 1;Pe = length(find(x - 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,m*-)xlabel(10log_10(P/J)(W/R) (dB)ylabel(BER)s=sprintf(BER versus 10log_10(P/J)(W/R) in pulsed noise jammin
31、g and AWGN);title(s);%*% This program computes the average BER of a DS-SS/BPSK %communication system in barrage noise jamming and AWGN% % AUTHOR: Wenbin Luo% DATE : 05/02/01%final12_extra.m% %*% function Plot_Pe = final12_extra()clear all;%close all;format long;%set up the threshold Vt Vt = 0;Plot_P
32、e = ;N = 16;x_num = 10000;%-%convert back from dBEb_No = 5; % 2, 4, 6 dB Eb_No = 10.(Eb_No/10);%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;
33、%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 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
34、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%-%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=s
35、printf(BER versus 10log_10(P/J)(W/R) in barrage noise jamming and AWGN);title(s);grid on;%*% This program computes the average BER in Rayleigh fading %and AWGN% % AUTHOR: Wenbin Luo% DATE : 04/28/01%final21.m% %*%function Plot_Pe = final21()clear all;%close all;format long;%set up the threshold Vt V
36、t = 0;Plot_Pe = ;N = 16;x_num = 10000;plot_EbNo = -30:2:30; %-20:2:10;for EbNo = -30:2:30, %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(
37、x_num);x_original = x;x = sqrt(p)*x;%generate Rayleigh fadingenv,phi = fade(length(x),0.5);%generate faded 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 demodula
38、te symbols with user codex_de = ds_demod(c(:),y);%decisionx_de(find(x_de =0) = 1;Pe = length(find(x_original - 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)yla
39、bel(BER)s=sprintf(BER versus Eb/No in Rayleigh fading and AWGN);title(s);grid on;%*% This program simulates a predetection selective combining%receiver for a Rayleigh fading channel % % AUTHOR: Wenbin Luo% DATE : 04/28/01%final21_extra.m% %*clear all;%close all;format long;%set up the threshold Vt V
40、t = 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 = 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(
41、x_num);x_original = x;x = sqrt(p)*x;%generate Rayleigh fadingenv1,env2 = fade_diversity(length(x),0.5);%generate faded sequencex_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
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2025全员安全培训考试试题完美
- 2024-2025管理人员岗前安全培训考试试题及参考答案
- 2025年土地流转相关合同范本
- 2025年订单合同范文
- 2025防水涂料采购合同范本
- 2025年度摩托车租赁合同
- 2025年长春市房屋租赁合同范本
- 2025年车用交流发电机合作协议书
- 2025流动资产外汇借款合同
- 2025竹林买卖合同模板
- JCT 932-2013 卫生洁具排水配件
- 2024年工程承包合同书范文
- 有限空间作业风险辨识管控台帐
- 中学教材、教辅资料征订管理制度
- 急性胰腺炎急诊诊治专家共识2024解读
- 加油站防雷应急预案方案
- 排列五历史开奖数据(2004年11月至2013年7月)
- 施工现场消防培训课件
- 16学时《中医药膳学》教学大纲(可编辑修改文本版)
- 科技创新推动2024年的经济发展
- 死因监测培训课件
评论
0/150
提交评论