0

I am now doing a MATLAB for calculating the capacity of a MIMO channel with CSI. Therefore, I need to use water filling to have the power level....but I have some problem that the result graph is concave downward. can anyone give me some suggesting where I did it wrong??

clear 
nr=2;
nt=2;
minN = min(nr,nt);
transmitSNR = -20;

for k=1:21     %- set the value of Po/No in dB 
for m=1:1000

    for t=1:nr
        for y=1:nt
             a=1/sqrt(2)*randn(nr,nt);
             b=1/sqrt(2)*randn(nr,nt);
             H=a+1i*b;  %- complex form of H 
         end
    end        
   %- Hr=R^1/2*H;        
    [S V D]=svd(H);
    cap(m)=0;
    for n=1:1:minN        
        lambda(n) = V(n,n);
    end

        [lambda L] = sort(lambda,'descend');
        lambda = lambda(find(lambda > 0));      % ignoring non-positive eigenvalues
        pl = -1;
        try
            while (min(pl) < 0)
                mu = (transmitSNR + sum(1 ./ lambda)) / length(lambda);
                pl = mu - 1 ./ lambda;
                lambda = lambda(1:end-1);
            end
        catch
            disp('There exists no water filling level for the input eigenvalues. Check your data and try again')
        end
        pl = [pl; zeros(length(L) - length(pl), 1)]; % assigning zero power for weak eigen-modes 
        pl(L) = pl;

        for n=1:1:minN
             cap(m) = cap(m) + sum( log2(1 + pl(n).*lambda));

        end
    end           

capacity(k)=mean(cap);
SNR(k) = transmitSNR;
transmitSNR = transmitSNR+2;    
end
plot (SNR,capacity,'d-m'); hold on;
title('Graph of SNR & channel capacity');
xlabel('SNR,dB');
ylabel('Channel capacity');
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
  • In case there is a problem with the algorithm and not with your code a better place could be http://dsp.stackexchange.com/. – Dirk Feb 12 '14 at 10:55

1 Answers1

0

My solution for the problem above is:

SNR_dB=-20; % Here is your SNR in dB
transmitSNR=10.^(SNR_dB./10); % Here is the conversion
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
  • 3
    Welcome to Stack Overflow! Please consider editing your post to add more explanation about what your code does and why it will solve the problem. An answer that mostly just contains code (even if it's working) usually wont help the OP to understand their problem. – SuperBiasedMan Sep 17 '15 at 17:46