# Sum 2 Matrices and take the average value of their summation and store them in another Matrix with the same dimension.

1 vue (au cours des 30 derniers jours)
Matthew Worker le 15 Déc 2021
Commenté : Rena Berman le 16 Déc 2021
% in this code, I import 2 text files, C_Total_1 and C_Total_2. I want to take the average of the sum of these two variables, then store the new value in C_Total_up. What I should change in this code.
clc;
clear;
N = (6:10).^2; %Number of Elements IRS
K = 6:10; %Number of Single Antennas UE
C_Total_1 = importdata('C_Total_1.txt') ; % Total Capacity
C_Total_2 = importdata('C_Total_2.txt') ; % Total Capacity
P = 'C:\Users\tripo\Documents\Total_Active_up_Capacity\ART';
Total_File = [1,2];
Total_Capacity_File = numel(Total_File);
C_Total = cell(1,Total_Capacity_File);
for i = 1:Total_Capacity_File
F_Total = sprintf('C_Total_%d.txt',Total_File(i));
C_Total{i} = importdata(fullfile(P,F_Total));
end
C_Total_up = vertcat(C_Total{:});
##### 2 commentairesAfficher AucuneMasquer Aucune
Image Analyst le 15 Déc 2021
Original question attached.
Rena Berman le 16 Déc 2021

Connectez-vous pour commenter.

### Réponse acceptée

Jan le 15 Déc 2021
Modifié(e) : Jan le 15 Déc 2021
"I want to take the average of the sum of these two variables, then store the new value in C_Total_up"
C_Total_up = (C_Total_1 + C_Total_2) / 2
And if you have multiple data sets stored in a cell:
C_Total_up = sum(cat(3, C_Total{:}), 3) / numel(C_Total);
% Or:
C_Total_up = mean(cat(3, C_Total{:}), 3);
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Whos dans Help Center et File Exchange

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by