function [CAP] = capacityEMOS(HH,SNR,normalize) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [CAP] = capacityEMOS(HH,SNR) %% % %% % This function was build to calculate the capacity %% % of the estimated EMOS channels. It first normalizes %% % the channel gains, such that E(|h_{i,j}|^2) = 1, %% % where the avaraging is done over all snapshots and %% % all frequencies. %% % - [CAP] is the capacity values; %% % - HH is the input channel (M_Rx,M_Tx,fq,Channels) %% % - SNR is the considered SNR (Linear) %% % %% % Created: 25/04/2007 by delacerd@eurecom.fr %% % Modified last: 10/10/2007 by florian.kaltenberger@eurecom.fr %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% [M_Rx,M_Tx,N_fq,N_channel] = size(HH); % fk: I don't think this code is correct. % tmp = zeros(N_fq,N_channel); % for kk = 1:N_channel, % tmp1 = 0; % for ii = 1:N_fq, % var1(:,:,ii,kk) = HH(:,:,ii,kk)*HH(:,:,ii,kk)'; % tmp1 = tmp1 + norm(var1(:,:,ii,kk),'fro'); % end % PP = tmp1/N_fq; % var1 = (M_Rx/PP) * var1; % for ii = 1:N_fq, % tmp(ii,kk) = abs(log2(det(diag(ones(M_Rx,1)) + SNR * var1(:,:,ii,kk)))); % ForPDF(ii,kk) = trace(M_Tx*var1(:,:,ii,kk)); % end % end if nargin<3 normalize = 1; end if normalize % Normalization of H, such that E(|h_{i,j}|^2) = 1! var1 = complex(zeros(M_Rx,M_Rx,N_fq,N_channel)); tmp = 0; for ii = 1:N_fq, for kk = 1:N_channel, % this is the frobenious norm of HH var1(:,:,ii,kk) = HH(:,:,ii,kk)*HH(:,:,ii,kk)'; tmp = tmp + trace(var1(:,:,ii,kk)); end end PP = tmp/(N_fq*N_channel); else PP = 1; end % HH = HH*sqrt(M_Rx*M_Tx/PP); % now E(|h_{i,j}|^2) = 1! % Capacity estimation tmp = zeros(N_fq,N_channel); % ForPDF = zeros(N_fq,N_channel); for ii = 1:N_fq, for kk = 1:N_channel, % the following two lines are the same, the second one should be % more efficient tmp(ii,kk)=abs(log2(det(diag(ones(M_Rx,1)) + (SNR/M_Tx) * HH(:,:,ii,kk) * HH(:,:,ii,kk)'))); % tmp(ii,kk)=abs(log2(det(diag(ones(M_Rx,1)) + (M_Rx*SNR/PP) * % var1(:,:,ii,kk)))); % ForPDF(ii,kk) = trace(M_Tx*var1(:,:,ii,kk)); end end % ForPDF = reshape(ForPDF,1,N_fq*N_channel); if N_channel == 1, % if we are analyzing one single frame the output is a value CAP = mean(tmp); % CAP = (tmp); else % if we are analyzing a sequence of frames, the output is a vector with all capacity values CAP = reshape(tmp,1,N_fq*N_channel); end