Takin the mean of data in tables

1 次查看(过去 30 天)
I have his table
X1=[9 6 9;3 2 7];
X2=[0 2;4 0];
X3=[3 1 2; 8 9 7];
X=table(X1,X2,X3)
X = 2×3 table
X1 X2 X3 ___________ ______ ___________ 9 6 9 0 2 3 1 2 3 2 7 4 0 8 9 7
And I need to take the mean of the rows in each entry, which would give me
m1=[8 4]', m2=[1 2]' and m3=[2 8]'.
Can this be done efficiently?

采纳的回答

KSSV
KSSV 2021-11-16
X1=[9 6 9;3 2 7];
X2=[0 2;4 0];
X3=[3 1 2; 8 9 7];
X=table(X1,X2,X3) ;
[m,n] = size(X) ;
iwant = zeros(2,n) ;
for i = 1:n
iwant(:,i) = mean(X.(i),2) ;
end
iwant
iwant = 2×3
8 1 2 4 2 8
  3 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by