Takin the mean of data in tables

조회 수: 4 (최근 30일)
Sebastian Daneli
Sebastian Daneli 2021년 11월 16일
댓글: Sebastian Daneli 2021년 11월 16일
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
KSSV
KSSV 2021년 11월 16일
iwant = mean(table2array(X),2)
Sebastian Daneli
Sebastian Daneli 2021년 11월 16일
@KSSV, perfect. Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (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