您现在的位置:首页 >> 技术文章 >> MATLAB技术 >> 内容

MATLAB代做|FPGA代做|python代做- 合作多样性

时间:2021-2-21 14:19:29 点击:

  核心提示:MATLAB代做|FPGA代做|python代做- 合作多样性...
%Cooperative Diversity - Main Sequence
tic
% --------------
% Set Parameters
nr_of_iterations = 10^3;
SNR = [-10:2.5:15];
use_direct_link = 1;
use_relay = 1;
global statistic;
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 = 'MRC'; %'ERC','FRC','SNRC','ESNRC','MRC'
rx(1).sd_weight = 3;
global relay;
relay = generate_relay_structure;
relay(1).mode = 'DAF'; %'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).attenuation.d = 1 / (channel(1).attenuation.distance ^ 2);
% Path loss is constant for the whole transmission
switch channel(1).attenuation.pattern
case 'no'
% No fading at all (only path loss)
channel(1).attenuation.phi = zeros(size(signal.symbol_sequence));
channel(1).attenuation.h = ones(size(signal.symbol_sequence)) * ...
channel(1).attenuation.d;
channel(1).attenuation.h_mag = channel(1).attenuation.h;
case 'Rayleigh'
% Rayleigh fading and path loss
nr_of_blocks = ceil(size(signal.symbol_sequence,2) /...
channel(1).attenuation.block_length);
h_block = (randn(nr_of_blocks,1) + j * randn(nr_of_blocks...
,1)) * channel(1).attenuation.d;
h = reshape((h_block * ...
ones(1, channel(1).attenuation.block_length))', 1,...
channel(1).attenuation.block_length * nr_of_blocks);
channel(1).attenuation.h = h(1:(size(signal.symbol_sequence,2)));
[channel(1).attenuation.phi, channel(1).attenuation.h_mag] =...
cart2pol(real(channel(1).attenuation.h),...
imag(channel(1).attenuation.h));
channel(1).attenuation.phi = -channel(1).attenuation.phi;
otherwise
error(['Fading-pattern unknown: ',...
channel(1).attenuation.pattern])
end

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 transmiss% add2statistic(SNR,ber_2_senders(SNR_linear, 'QPSK'),'QPSK - 2 senders')
show_statistic;
toc

联系:highspeedlogic

QQ :1224848052

微信:HuangL1121

邮箱:1224848052@qq.com

网站:http://www.mat7lab.com/

网站:http://www.hslogic.com/

微信扫一扫:

作者:不详 来源:网络
  • 您是如何找到本站的?
  • 百度搜索
  • Google搜索
  • 查阅资料过程中
  • 论坛发现
  • 百度贴吧发现
  • 朋友介绍
本站最新成功开发工程项目案例
相关评论
发表我的评论
  • 大名:
  • 内容:
  • matlab代做|matlab专业代做|matlab淘宝代做|python人工智能代做|FPGA项目合作|C代做|C++代做(www.hslogic.com) © 2021 版权所有 All Rights Reserved.
  • Email:highspeed_logic@163.com 站长QQ: 1224848052

    专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文,毕业论文,Coursework、Eassy、Assignment