You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

84 lines
2.5 KiB

function RU_avai = Corrcoef_Calculate(staFeedback,Type, jam_data)
numUsers = length(staFeedback);
[Nst,numRx,numSTS] = size(staFeedback{1});
% combine_matrix = zeros(Nst,numRx*numUsers,numSTS);
% 将反馈矩阵按用户纵向拼接
combine_matrix = cell(1,numRx);
Nru = 4;
RU_avai = zeros(1,Nru);
for rxIdx = 1:numRx
combine_matrix{rxIdx} = zeros(Nst,numUsers,numSTS);
for userIdx = 1:numUsers
combine_matrix{rxIdx}(:,userIdx,:) = staFeedback{userIdx}(:,rxIdx,:);
end
ru1 = combine_matrix{rxIdx}(1:52,:,:);
ru2 = combine_matrix{rxIdx}(54:105,:,:);
ru3 = combine_matrix{rxIdx}(138:190,:,:);
ru4 = combine_matrix{rxIdx}(191:end,:,:);
RU_matrix = {ru1,ru2,ru3,ru4};
for ruIdx = 1:Nru
fprintf('第%d个RU:\n',ruIdx);
% 计算每个空间流在不同接收天线下的相关系数
Coefs = cell(1,numSTS);
num_corr = zeros(1,numSTS);
disp('每个空间流的信道相关系数矩阵为:');
for stsIdx = 1:numSTS
Coef = corrcoef(abs(RU_matrix{ruIdx}(:,:,stsIdx)));
Coef(logical(eye(size(Coef)))) = -1;
Coefs{stsIdx} = Coef;
disp(Coef);
num_corr(stsIdx) = sum(Coef>0.5,'all');
end
disp('相关系数大于0.5的天线为:');
disp(num_corr);
if sum(num_corr) == 0
RU_avai(ruIdx) = RU_avai(ruIdx)+1;
end
end
end
% figure();
% for rxIdx = 1:numRx
% for stsIdx = 1:numSTS
% for userIdx = 1:numUsers
% plot(abs(combine_matrix{rxIdx}(:,userIdx,stsIdx)));
% hold on;
% end
% end
% end
% hold off;
% pause(0.5);
% close;
% 判断频谱干扰对RU的影响
if strcmp(Type,'multi')
for Idx = 1:length(jam_data)
f_idx = jam_data{1}(Idx)/10*Nst;
if 1 < f_idx < 52
RU_avai(1) = RU_avai(1)-0.5;
elseif 54 < f_idx < 105
RU_avai(2) = RU_avai(2)-0.5;
elseif 138 < f_idx < 190
RU_avai(3) = RU_avai(3)-0.5;
elseif 191 < f_idx < Nst
RU_avai(4) = RU_avai(4)-0.5;
end
end
elseif strcmp(Type,'mono')
f_idx = jam_data/10*Nst;
if 1 < f_idx < 52
RU_avai(1) = RU_avai(1)-0.5;
elseif 54 < f_idx < 105
RU_avai(2) = RU_avai(2)-0.5;
elseif 138 < f_idx < 190
RU_avai(3) = RU_avai(3)-0.5;
elseif 191 < f_idx < Nst
RU_avai(4) = RU_avai(4)-0.5;
end
end
fprintf('4个RU中可用的RU为:');
disp(RU_avai);
end