How to average certain columns in a matrix

12 visualizaciones (últimos 30 días)
Gregory Manoukian
Gregory Manoukian el 2 de Jul. de 2021
Respondida: madhan ravi el 2 de Jul. de 2021
I have a 107x16 matrix, the first column is time data, the last 15 are data points. I'd like to average the 15 data columns and collapse this matrix into a 107x2 matrix of time and average data.
Thank you!

Respuesta aceptada

madhan ravi
madhan ravi el 2 de Jul. de 2021
Editada: madhan ravi el 2 de Jul. de 2021
matrix = rand(107, 16);
Matrix = [matrix(:, 1), mean(matrix(:, 2 : end), 2)];
size(Matrix)
ans = 1×2
107 2

Más respuestas (1)

madhan ravi
madhan ravi el 2 de Jul. de 2021
T = array2table(rand(2, 3))
T = 2×3 table
Var1 Var2 Var3 _______ _______ _______ 0.8811 0.32473 0.53106 0.63365 0.29403 0.93199
T = [T(:, 1), array2table(mean(T{:, 2 : end}, 2), 'V', {'AVERAGE'})] % where Var1 is the time data
T = 2×2 table
Var1 AVERAGE _______ _______ 0.8811 0.4279 0.63365 0.61301

Categorías

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

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by