Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. %% C=CvsSNR_EqualPowerAllocation(SNRvec_db, H, calcType)
  2. % C = log_2 |I_N_r + (p/N_t)H'H'^H|
  3.  
  4. function C=CvsSNR_EqualPowerAllocation(SNRvec_db, H, calcType)
  5. [m,n] = size(H); %n=t, m=r
  6. I_Nr = eye(m);
  7. C = zeros(1, length(SNRvec_db));
  8.  
  9. %% If CalcType = 1, then we want to use 3.9
  10. if (calcType == 1)
  11.     for i = 1:(length(SNRvec_db))
  12.         C(i) = log2(det(I_Nr+(SNRvec_db(i)/n)*H*H'));
  13.    end
  14.    return;
  15. %% If CalcType = 1, then we want to use 3.11
  16. elseif (calcType == 2)
  17.    [U,S,V] = svd(H);
  18.    r = rank(H);
  19.    lambda_i = diag(S);
  20.    for i = 1:(length(SNRvec_db))
  21.        for j = 1:r
  22.            C(i) = C(i) + log2(1+(SNRvec_db(i)/n)*lambda_i(j));
  23.        end
  24.    end
  25.    return;
  26. else
  27.    fprintf("Unknown calcType");
  28.    return;
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement