How to average certain columns in a matrix
3 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
madhan ravi
2021-7-2
编辑:madhan ravi
2021-7-2
matrix = rand(107, 16);
Matrix = [matrix(:, 1), mean(matrix(:, 2 : end), 2)];
size(Matrix)
0 个评论
更多回答(1 个)
madhan ravi
2021-7-2
T = array2table(rand(2, 3))
T = [T(:, 1), array2table(mean(T{:, 2 : end}, 2), 'V', {'AVERAGE'})] % where Var1 is the time data
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!