How to calculate a mean of column one across multiple tables?

18 ビュー (過去 30 日間)
Tomaszzz
Tomaszzz 2022 年 3 月 16 日
コメント済み: Tomaszzz 2022 年 3 月 16 日
Hi all,
I have a 21x1 cell with 100x 18 tables (attached).
What I am seeking to do is to calcuate mean of:
row 1, column1, all tables
row 2, column1, all tables
....
row 100, column 1, all tables
Repeat for remaining 17 columns
So ultimately, I will have a table 100x18.
For example: for column 1
P_acc_z = (t{1,1.P_acc_z_meancycle} + t{2,1.P_acc_z_meancycle}, + t{3,1.P_acc_z_meancycle}+ ...., + t{18,1.P_acc_z_meancycle})/18
Can you help please?

採用された回答

David Hill
David Hill 2022 年 3 月 16 日
m=sum(arrayfun(@(x)sum(table2array(c{x}(:,1))),1:18))/1800;% c is your cell array, this finds mean of first columns
loop to find means of all columns.
for k=1:18
m(k)=sum(arrayfun(@(x)sum(table2array(c{x}(:,k))),1:18))/1800;
end
  4 件のコメント
Tomaszzz
Tomaszzz 2022 年 3 月 16 日
thanks!
Tomaszzz
Tomaszzz 2022 年 3 月 16 日
I have a couple of tables which have only nan values in a single column which results in having nan values for a mean for this particular column. Is there a way to omit nan values?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by