1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| clc;clear;close all; symbol_count = 1000; K = 1; N_t = 1;
modulation = sqrt(1/10)*[-3+3*1i, -1+3*1i, +1+3*1i, +3+3*1i, -3+1*1i, -1+1*1i, +1+1*1i, +3+1*1i, -3-1*1i, -1-1*1i, +1-1*1i, +3-1*1i, -3-3*1i, -1-3*1i, +1-3*1i, +3-3*1i];
MT_count = 100;
channel_K_all = sqrt(1/2)*(randn(K, N_t, MT_count)+1i*randn(K, N_t, MT_count));
all = possible_generator(length(modulation),K);
possible=length(all);
for mt = 1:MT_count snrs = -10:1:30; for i = 1:length(snrs) channel_K = repmat(channel_K_all(:, :, mt), [1, 1, symbol_count]); W_LS = zeros(N_t, K); W_MRT = zeros(N_t, K); H = squeeze(channel_K(:, :, 1)).'; for k = 1:K W_LS(:, k) = H(:, k) / norm(H(:, k)); W_MRT(:, k) = conj(H(:, k)) / norm(H(:, k))^2; end W_ZF = H / (H' * H); for k = 1:K W_ZF(:, k) = W_ZF(:, k) / norm(W_ZF(:, k)); end W_LS = W_LS./norm(W_LS, 'fro'); W_MRT = W_MRT./norm(W_MRT, 'fro'); W_ZF = W_ZF./norm(W_ZF, 'fro');
W = W_ZF;
for k = 1:K symbols_K(k, :) = ceil(length(modulation)*rand(1,symbol_count)); tx_K(k, :) = modulation(symbols_K(k, :)); end for k = 1:K N0 = 1/(10^(snrs(i)/10)); noise = sqrt(N0/2)*(randn(1,symbol_count)+1i*randn(1,symbol_count)); rx_k(k, :) = tx_K(k, :).*reshape(squeeze(channel_K(k, :, :)).'*W(:, k), size(tx_K(k, :)))+noise; for kk=1:K if kk ~= k rx_k(k, :) = rx_k(k, :) + tx_K(kk, :).*reshape(squeeze(channel_K(k, :, :)).'*W(:, kk), size(tx_K(k, :))); end end end result_with_N_t = zeros(possible,N_t); for j=1:possible for k = 1:K result_with_N_t(j, :) = result_with_N_t(j, :)+W(:, k).'*modulation(all(j,k)); end end probabilities = zeros(possible, symbol_count); for k = 1:K probabilities = max(probabilities, max(exp(-(abs(ones(possible,1)*rx_k(k, :) - result_with_N_t*reshape(squeeze(channel_K(k, :, :)), [], symbol_count)).^2)/N0),realmin)); end probabilities = probabilities ./ sum(probabilities, 1); mt_channel_capacity(i, mt) = (log2(possible)+mean(sum(probabilities.*log2(probabilities))))/K; end end channel_capacity = mean(mt_channel_capacity, 2); figure(1) plot(snrs,channel_capacity) hold off;
function all=possible_generator(M,dc) number =(0:M^dc-1); p_unsort=zeros(M^dc,dc); for i=1:dc if i==1 p_unsort(:,i)=floor(number./M^(dc-i))'; else temp=zeros(M^dc,1); for j=1:i-1 temp=p_unsort(:,j).*M^(dc-j)+temp; end p_unsort(:,i)=floor((number'-temp)./M^(dc-i)); end end all=p_unsort+1; end
|