16QAM simulation in Rayleigh Channel源码程序 - matlab通信信号 - 谷速源码
下载频道> 资源分类> matlab源码> 通信信号> 16QAM simulation in Rayleigh Channel源码程序

标题:16QAM simulation in Rayleigh Channel源码程序
分享到:

所属分类: 通信信号 资源类型: 文件大小: 2.06 KB 上传时间: 2016-01-30 12:20:32 下载次数: 9 资源积分:1分 提 供 者: 源码共享 20160130121850535
内容:
16QAM simulation in Rayleigh Channel源码程序,程序员在编程的过程中可以参考学习使用,希望对IT程序员有用,此源码程序简单易懂、方便阅读,有很好的学习价值!
% Clear all the previously used variables and close all figures
clear all;
close all;
 
format long;
 
% Frame Length 'Should be multiple of four or else padding is needed'
bit_count = 1*1000;
 
% Range of SNR over which to simulate 
Eb_No = 0: 1: 10;
 
% Convert Eb/No values to channel SNR
 
SNR = Eb_No + 10*log10(4);
 
% Start the main calculation loop
for aa = 1: 1: length(SNR)
    
    % Initiate variables
    T_Errors = 0;
    T_bits = 0;
    
    % Keep going until you get 100 errors
    while T_Errors < 100
    
        % Generate some random bits
        uncoded_bits  = round(rand(1,bit_count));
 
        % Split the stream into 4 substreams
        B = reshape(uncoded_bits,4,length(uncoded_bits)/4);
        B1 = B(1,:);
        B2 = B(2,:);
        B3 = B(3,:);
        B4 = B(4,:);
        
        % 16-QAM modulator
        % normalizing factor
        a = sqrt(1/10);
 
        % bit mapping
        tx = a*(-2*(B3-0.5).*(3-2*B4)-j*2*(B1-0.5).*(3-2*B2));
        
         % Variance = 0.5 - Tracks theoritical PDF closely
        ray = sqrt((1/2)*((randn(1,length(tx))).^2+(randn(1,length(tx))).^2));
        
        % Include The Fading
        rx = tx.*ray;
        
        % Noise variance
        N0 = 1/10^(SNR(aa)/10);
 
        % Send over Gaussian Link to the receiver
        rx = rx + sqrt(N0/2)*(randn(1,length(tx))+1i*randn(1,length(tx)));
        
%---------------------------------------------------------------
 
        % Equaliser
        rx = rx./ray;
        
        % 16-QAM demodulator at the Receiver
        a = 1/sqrt(10);
 
        B5 = imag(rx)<0;
        B6 = (imag(rx)<2*a) & (imag(rx)>-2*a);
        B7 = real(rx)<0;
        B8 = (real(rx)<2*a) & (real(rx)>-2*a);
        
        % Merge into single stream again
        temp = [B5;B6;B7;B8];
        B_hat = reshape(temp,1,4*length(temp));
    
        % Calculate Bit Errors
        diff =  uncoded_bits - B_hat ;
        T_Errors = T_Errors + sum(abs(diff));
        T_bits = T_bits + length(uncoded_bits);
        
    end
    % Calculate Bit Error Rate
    BER(aa) = T_Errors / T_bits;
    disp(sprintf('bit error probability = %f',BER(aa)));
    
    % Plot the received Symbol Constellation
    figure;
    grid on;
    plot(rx,'x');
    xlabel('Inphase Component');
    ylabel('Quadrature Component');
    Title(['Constellation of Transmitted Symbols for SNR =',num2str(SNR(aa))]);
 
 
end
  
%------------------------------------------------------------
 
% Finally plot the BER Vs. SNR(dB) Curve on logarithmic scale 
% BER through Simulation
 
figure(1);
semilogy(Eb_No,BER,'xr-','Linewidth',2);
hold on;
xlabel('E_b / N_o (dB)');
ylabel('BER');
title('E_b / N_o Vs BER plot for 16-QAM Modualtion in Rayleigh Channel');
 
% Theoretical BER
figure(1);
theoryBerAWGN = 0.5.*erfc(sqrt((10.^(Eb_No/10))));
semilogy(Eb_No,theoryBerAWGN,'g-+','Linewidth',2);
grid on;
legend('Rayleigh', 'AWGN');
axis([Eb_No(1,1) Eb_No(end) 0.00001 1]);

文件列表(点击上边下载按钮,如果是垃圾文件请在下面评价差评或者投诉):

16QAM simulation in Rayleigh Channel源码程序/
16QAM simulation in Rayleigh Channel源码程序/16 QAM simulation in Rayleigh Channel/
16QAM simulation in Rayleigh Channel源码程序/16 QAM simulation in Rayleigh Channel/BER_16_QAM_rayleigh.m

关键词: 源码 程序

Top_arrow
回到顶部
联系方式| 版权声明| 招聘信息| 广告服务| 银行汇款| 法律顾问| 兼职技术| 付款方式| 关于我们|
网站客服网站客服 程序员兼职招聘 程序员兼职招聘
沪ICP备19040327号-3
公安备案号:沪公网安备 31011802003874号
库纳格流体控制系统(上海)有限公司 版权所有
Copyright © 1999-2014, GUSUCODE.COM, All Rights Reserved