⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 problem_5_3_b.m

📁 Ultra.Wideband.Signals.and.Systems.in.Communication.Engineering.eBook-kB代码
💻 M
字号:
%% Solution for problem 5.3%
% calculation of curves for beta=5,500
%
clear;
beta = 500;
Nu = [1:10,20:10:100,200:100:1000];  % Number of Users
M = 32;     %Number of PPM positions
Ep = 1;     % Energy of pulse
No = 0.05;  % Noise value
simnum = 1000;
%
% rho
%
rho0=2*Ep/No;
%rho0=12.5;
rhoI=(3*beta)./((Nu-1)+(3*beta/rho0))  % channel symbol SNR
%
% r.v. simulation
%
total = 0;
for s=1:simnum
    sum =1;
    v1=normrnd(sqrt(rhoI),1);
    %v1 = 3.46;
    for m=2:M   
        vm=normrnd(0,1);
        %vm = 0;
        temp = exp(sqrt(rhoI).*(vm-v1));
        sum = sum + temp;
    end;
    CM = log2(M) - log2(sum);
    total = total + CM;
end
capacity = total/simnum
%
% plot the graph
%
semilogx(Nu,capacity,'-^')
grid;axis([0 1000 0 5]);
ylabel('Capacity (bits/symbol)')
xlabel('Number of Users')
title('Number of Users vs Capacity (bits/symbol), \beta=500')
hold;



M = 16;     %Number of PPM positions
%
% r.v. simulation
%
total = 0;
for s=1:simnum
    sum =1;
    v1=normrnd(sqrt(rhoI),1);
    for m=2:M   
        vm=normrnd(0,1);
        temp = exp(sqrt(rhoI).*(vm-v1));
        sum = sum + temp;
    end;
    CM = log2(M) - log2(sum);
    total = total + CM;
end
capacity = total/simnum
semilogx(Nu,capacity,'-v') % plot the graph for M=16




M = 8;     %Number of PPM positions
%
% r.v. simulation
%
total = 0;
for s=1:simnum
    sum =1;
    v1=normrnd(sqrt(rhoI),1);
    for m=2:M   
        vm=normrnd(0,1);
        temp = exp(sqrt(rhoI).*(vm-v1));
        sum = sum + temp;
    end;
    CM = log2(M) - log2(sum);
    total = total + CM;
end
capacity = total/simnum
semilogx(Nu,capacity,'-s') % plot the graph for M=8




M = 4;     %Number of PPM positions
%
% r.v. simulation
%
total = 0;
for s=1:simnum
    sum =1;
    v1=normrnd(sqrt(rhoI),1);
    for m=2:M   
        vm=normrnd(0,1);
        temp = exp(sqrt(rhoI).*(vm-v1));
        sum = sum + temp;
    end;
    CM = log2(M) - log2(sum);
    total = total + CM;
end
capacity = total/simnum
semilogx(Nu,capacity,'-+') % plot the graph for M=4






M = 2;     %Number of PPM positions
%
% r.v. simulation
%
total = 0;
for s=1:simnum
    sum =1;
    v1=normrnd(sqrt(rhoI),1);
    for m=2:M   
        vm=normrnd(0,1);
        temp = exp(sqrt(rhoI).*(vm-v1));
        sum = sum + temp;
    end;
    CM = log2(M) - log2(sum);
    total = total + CM;
end
capacity = total/simnum
semilogx(Nu,capacity,'-*') % plot the graph for M=2

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -