clc;
clear;
close all;
warning off;
addpath(genpath(pwd));
%****************************************************************************
%更多关于matlab和fpga的搜索“fpga和matlab”的CSDN博客:
%matlab/FPGA项目开发合作
%https://blog.csdn.net/ccsss22?type=blog
%****************************************************************************
tic
% --------------
% Set Parameters
nr_of_iterations = 10^3;
SNR = [-10:2.5:15];
use_direct_link = 1;
use_relay = 1;
global statistic;
%!!! comment the following line for keeping the statistics of several runs
statistic = generate_statistic_structure;
global signal;
signal = generate_signal_structure;
signal(1).nr_of_bits = 2^10;
signal.modulation_type = 'QPSK'; % 'BPSK', 'QPSK'
calculate_signal_parameter;
channel = generate_channel_structure;
channel(1).attenuation(1).pattern = 'Rayleigh';% 'no','Rayleigh'
channel.attenuation.block_length = 1;
channel(2) = channel(1);
channel(3) = channel(1);
channel(1).attenuation.distance = 1;
channel(2).attenuation.distance = 1;
channel(3).attenuation.distance = 1;
rx = generate_rx_structure;
rx(1).combining_type = 'ESNRC'; %'ERC','FRC','SNRC','ESNRC','MRC'
rx(1).sd_weight = 3;
global relay;
relay = generate_relay_structure;
relay(1).mode = 'AAF'; %'AAF', 'DAF'
relay.magic_genie = 0;
relay(1).rx(1) = rx(1); % same beahaviour
% ----------------
% Start Simulation
BER = zeros(size(SNR));
for iSNR = 1:size(SNR,2)
channel(1).noise(1).SNR = SNR(iSNR);
channel(2).noise(1).SNR = SNR(iSNR);
channel(3).noise(1).SNR = SNR(iSNR);
disp(['progress: ',int2str(iSNR),'/',int2str(size(SNR,2))])
for it = 1:nr_of_iterations;
% --------------
% Reset receiver
rx = rx_reset(rx);
relay.rx = rx_reset(relay.rx);
% -----------
% Direct link
if (use_direct_link == 1)
[channel(1), rx] = add_channel_effect(channel(1), rx,...
signal.symbol_sequence);
rx = rx_correct_phaseshift(rx, channel(1).attenuation.phi);
end
% ---------
% Multi-hop
if (use_relay == 1)
% Sender to relay
[channel(2), relay.rx] = add_channel_effect(channel(2),...
relay.rx, signal.symbol_sequence);
relay = prepare_relay2send(relay,channel(2));
% Relay to destination
[channel(3), rx] = add_channel_effect(channel(3), rx,...
relay.signal2send);
switch relay.mode
% Correct phaseshift
case 'AAF'
rx = rx_correct_phaseshift(rx,...
channel(3).attenuation.phi + channel(2).attenuation.phi);
case 'DAF'
rx = rx_correct_phaseshift(rx,channel(3).attenuation.phi);
end
end
% Receiver
[received_symbol, signal.received_bit_sequence] = ...
rx_combine(rx, channel, use_relay);
BER(iSNR) = BER(iSNR) + sum(not(...
signal.received_bit_sequence == signal.bit_sequence));
if (BER(iSNR) > 10000)
% Stop iterate
break;
end
end % Iteration
if (BER(iSNR)<100)
warning(['Result might not be precise when SNR equal ',...
num2str(SNR(iSNR))])
end
BER(iSNR) = BER(iSNR) ./ it ./ signal.nr_of_bits;
end
% ------------------------------------
% Present the result of the simulation
txt_distance = [' - distance: ',...
num2str(channel(1).attenuation.distance), ':',...
num2str(channel(2).attenuation.distance), ':',...
num2str(channel(3).attenuation.distance)];
txt_distance='';
if (use_relay == 1)
if (relay.magic_genie == 1)
txt_genie = ' - Magic Genie';
else
txt_genie = '';
end
txt_combining = [' - combining: ', rx(1).combining_type];
switch rx(1).combining_type
case 'FRC'
txt_combining = [txt_combining, ' ',...
num2str(rx(1).sd_weight),':1'];
end
add2statistic(SNR,BER,[signal.modulation_type, ' - ',...
relay.mode, txt_combining, txt_distance, txt_genie])
else
switch channel(1).attenuation.pattern
case 'no'
txt_fading = ' - no fading';
otherwise
txt_fading = ' - Rayleigh fading';
end
add2statistic(SNR,BER,[signal.modulation_type,txt_fading])
end
% % -----------------
% % Graphs to compare
SNR_linear = 10.^(SNR/10);
% add2statistic(SNR,ber(SNR_linear,'BPSK', 'Rayleigh'),'BPSK - single link transmission')
% add2statistic(SNR,ber_2_senders(SNR_linear, 'QPSK'),'QPSK - 2 senders')
show_statistic;
toc
matlab-基于matlab的协作通信链路误码率仿真QPSK调制,Rayleigh信道,ESNRC合并,AF协作-源码
版权申诉
156 浏览量
2021-09-21
20:27:30
上传
评论
收藏 13KB RAR 举报
mYlEaVeiSmVp
- 粉丝: 1935
- 资源: 19万+
最新资源
- 基于Java的本科探索学习项目设计源码 - 本科探索
- 基于Javascript和Python的微商城项目设计源码 - MicroMall
- 基于Java的网上订餐系统设计源码 - online ordering system
- 基于Javascript的超级美眉网络资源管理应用模块设计源码
- 基于Typescript和PHP的编程知识储备库设计源码 - study-php
- Screenshot_2024-05-28-11-40-58-177_com.tencent.mm.jpg
- 基于Dart的Flutter小提琴调音器APP设计源码 - violinhelper
- 基于JavaScript和CSS的随寻订购网页设计源码 - web-order
- 基于MATLAB的声纹识别系统设计源码 - VoiceprintRecognition
- 基于Java的微服务插件集合设计源码 - wsy-plugins
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈