Create table of means from multiple tables

15 visualizaciones (últimos 30 días)
Moira Pryhoda
Moira Pryhoda el 8 de Sept. de 2021
Respondida: David Hill el 8 de Sept. de 2021
I have 3 tables (204x32), each with the same column headers. I'd like to take the mean of each cell and create a new table with these means. For example, the first row and first column of output table T would be: T = (T1(1,1), T2(1,1), T3(1,1))/3. Thanks in advance for any help.

Respuesta aceptada

dpb
dpb el 8 de Sept. de 2021
Editada: dpb el 8 de Sept. de 2021
Simplest probably would be to convert to a 3D array and then use mean() along the third dimension....
tMeans=mean(cat(3,table2array(T1),table2array(T2),table2array(T3)),3);

Más respuestas (1)

David Hill
David Hill el 8 de Sept. de 2021
temp=T1.Properties.VariableNames;
T=array2table((T1{:,:}+T2{:,:}+T3{:,:})/3);
T.Properties.VariableNames=temp;

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by