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

📄 tu1-14.m

📁 我自己在学习空时编码一书时编写的第一章的仿真程序
💻 M
字号:
% n=64
SNR_dB=0:5:20;
SNR=10.^(SNR_dB./10);
n=64;
for k=1:length(SNR)
    simtimes=10000;
    C_E(simtimes)=0;%init
    for s=1:simtimes
        H=(randn(n,n)+j.*randn(n,n))./sqrt(2);
        C_E(s)=1./n.*log2(det(eye(n,n)+SNR(k)./n.*(H'*H)));
    end
    dx=0.01;
    [c,xout] = hist(C_E, 0:dx:10);
    pdf=c./simtimes./dx; %pdf fun
    %plot(xout,pdf);
    %sum(pdf).*dx %verify pdf fun
    plot(xout, 1-cumsum(pdf).*dx);hold on;
    axis([0 6 0 1.0]);grid on;
end
%%%n=32
SNR_dB=0:5:20;
SNR=10.^(SNR_dB./10);
n=32;
for k=1:length(SNR)
    simtimes=10000;
    C_E(simtimes)=0;%init
    for s=1:simtimes
        H=(randn(n,n)+j.*randn(n,n))./sqrt(2);
        C_E(s)=1./n.*log2(det(eye(n,n)+SNR(k)./n.*(H'*H)));
    end
    dx=0.01;
    [c,xout] = hist(C_E, 0:dx:10);
    pdf=c./simtimes./dx; %pdf fun
    %plot(xout,pdf);
    %sum(pdf).*dx %verify pdf fun
    plot(xout, 1-cumsum(pdf).*dx,':');hold on;
    axis([0 6 0 1.0]);grid on;
end
%%%n=16
SNR_dB=0:5:20;
SNR=10.^(SNR_dB./10);
n=16;
for k=1:length(SNR)
    simtimes=10000;
    C_E(simtimes)=0;%init
    for s=1:simtimes
        H=(randn(n,n)+j.*randn(n,n))./sqrt(2);
        C_E(s)=1./n.*log2(det(eye(n,n)+SNR(k)./n.*(H'*H)));
    end
    dx=0.01;
    [c,xout] = hist(C_E, 0:dx:10);
    pdf=c./simtimes./dx; %pdf fun
    %plot(xout,pdf);
    %sum(pdf).*dx %verify pdf fun
    plot(xout, 1-cumsum(pdf).*dx,':');hold on;
    axis([0 6 0 1.0]);grid on;
end
xlabel('容量n/(bit/s/Hz)');
ylabel('大于横坐标的概率 [容量n>横坐标的概率]');
text(0.4,0.52,'0dB');
text(1.1,0.52,'5dB');
text(2.2,0.52,'10dB');
text(3.5,0.52,'15dB');
text(5.0,0.52,'20dB');

⌨️ 快捷键说明

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